From 3ca182de175071efd64316a0c99a69064b1ab3b2 Mon Sep 17 00:00:00 2001 From: Henk-Jan Lebbink Date: Mon, 7 Jan 2019 11:24:25 +0100 Subject: [PATCH] Fixed warnings --- .../AsmDoc/AsmDocMouseHandler.cs | 8 +- VS/CSHARP/asm-dude-vsix/AsmDudePackage.cs | 12 - .../BraceMatching/BraceMatchingTagger.cs | 2 +- .../CodeCompletionCommandFilter.cs | 5 + .../CodeCompletion/CodeCompletionSource.cs | 28 +- .../CodeFolding/CodeFoldingTagger.cs | 3 +- .../QuickInfo/AsmQuickInfoController.cs | 22 +- .../QuickInfo/AsmQuickInfoSource.cs | 8 +- .../QuickInfo/AsmQuickInfoSourceProvider.cs | 5 +- .../InstructionTooltipWindow.xaml.cs | 66 +- .../QuickInfo/RegisterTooltipWindow.xaml.cs | 51 +- VS/CSHARP/asm-dude-vsix/Settings.Designer.cs | 2 +- .../Squiggles/SquigglesTagger.cs | 13 +- .../asm-dude-vsix/Tools/AsmDudeToolsStatic.cs | 77 +- VS/CSHARP/asm-dude-vsix/Tools/AsmSimulator.cs | 4 +- VS/CSHARP/asm-dude-vsix/Tools/LabelGraph.cs | 8 +- VS/CSHARP/asm-dude-vsix/app.config | 1153 ++++++++--------- VS/CSHARP/asm-dude-vsix/asm-dude-vsix.csproj | 24 +- VS/CSHARP/asm-irony/Example.cs | 2 +- VS/CSHARP/asm-irony/Example2.cs | 2 +- VS/CSHARP/asm-sim-lib/BitOperations.cs | 2 +- VS/CSHARP/asm-sim-lib/BranchInfo.cs | 4 +- VS/CSHARP/asm-sim-lib/DynamicFlow.cs | 8 +- VS/CSHARP/asm-sim-lib/GraphTools.cs | 4 +- VS/CSHARP/asm-sim-lib/Mnemonics.cs | 72 +- VS/CSHARP/asm-sim-lib/Runner.cs | 8 +- VS/CSHARP/asm-sim-lib/State.cs | 16 +- VS/CSHARP/asm-sim-lib/StateUpdate.cs | 56 +- VS/CSHARP/asm-sim-lib/StaticFlow.cs | 20 +- VS/CSHARP/asm-sim-lib/Tools.cs | 18 +- VS/CSHARP/asm-sim-lib/ToolsZ3.cs | 68 +- VS/CSHARP/asm-sim-lib/asm-sim-lib.csproj | 12 + VS/CSHARP/asm-sim-main/DotVisualizer.cs | 6 +- VS/CSHARP/asm-sim-main/ProgramZ3.cs | 2 +- VS/CSHARP/asm-tools-lib/Arch.cs | 2 +- VS/CSHARP/asm-tools-lib/AsmSourceTools.cs | 46 +- .../asm-tools-lib/ExpressionEvaluator.cs | 2 +- VS/CSHARP/asm-tools-lib/Flags.cs | 2 +- VS/CSHARP/asm-tools-lib/Mnemonic.cs | 4 +- VS/CSHARP/asm-tools-lib/Operand.cs | 4 +- VS/CSHARP/asm-tools-lib/RegisterTools.cs | 8 +- VS/CSHARP/unit-tests-asm-sim/TestTools.cs | 34 +- .../unit-tests-asm-sim/Test_BitTricks.cs | 24 +- .../unit-tests-asm-sim/Test_FlagTools.cs | 2 +- VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs | 40 +- .../test_AsmSourceTools.cs | 26 +- 46 files changed, 1029 insertions(+), 956 deletions(-) diff --git a/VS/CSHARP/asm-dude-vsix/AsmDoc/AsmDocMouseHandler.cs b/VS/CSHARP/asm-dude-vsix/AsmDoc/AsmDocMouseHandler.cs index d098458a..ac81befe 100644 --- a/VS/CSHARP/asm-dude-vsix/AsmDoc/AsmDocMouseHandler.cs +++ b/VS/CSHARP/asm-dude-vsix/AsmDoc/AsmDocMouseHandler.cs @@ -24,7 +24,6 @@ using System.Windows; using System.Windows.Input; using Microsoft.VisualStudio; -using Microsoft.VisualStudio.OLE.Interop; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Classification; @@ -402,7 +401,7 @@ private static void Evaluate(EnvDTE.Window WindowReference, Action((wb) => - { - BrowserUrl = wb.Url; - })); + Evaluate(WindowReference, new Action((wb) => BrowserUrl = wb.Url)); return BrowserUrl; } protected override void AttachInterfaces(object nativeActiveXObject) diff --git a/VS/CSHARP/asm-dude-vsix/AsmDudePackage.cs b/VS/CSHARP/asm-dude-vsix/AsmDudePackage.cs index 6c14dcf1..219e80c7 100644 --- a/VS/CSHARP/asm-dude-vsix/AsmDudePackage.cs +++ b/VS/CSHARP/asm-dude-vsix/AsmDudePackage.cs @@ -65,18 +65,6 @@ protected override async System.Threading.Tasks.Task InitializeAsync(Cancellatio { await base.InitializeAsync(cancellationToken, progress); ClearMefCache.ClearMefCache.Initialize(this); - - StringBuilder sb = new StringBuilder(); - sb.Append("Welcome to\n"); - sb.Append(" _____ ____ _ \n"); - sb.Append("| _ |___ _____ | \\ _ _ _| |___ \n"); - sb.Append("| |_ -| | | | | | | . | -_|\n"); - sb.Append("|__|__|___|_|_|_| |____/|___|___|___|\n"); - sb.Append("INFO: Loaded AsmDude version " + typeof(AsmDudePackage).Assembly.GetName().Version + " (" + ApplicationInformation.CompileDate.ToString() + ")\n"); - sb.Append("INFO: Open source assembly extension. Making programming in assembler almost bearable.\n"); - sb.Append("INFO: More info at https://github.com/HJLebbink/asm-dude \n"); - sb.Append("----------------------------------"); - await AsmDudeToolsStatic.OutputAsync(sb.ToString()); } #region Disassembly window experiments diff --git a/VS/CSHARP/asm-dude-vsix/BraceMatching/BraceMatchingTagger.cs b/VS/CSHARP/asm-dude-vsix/BraceMatching/BraceMatchingTagger.cs index 590b2636..ab7eaafc 100644 --- a/VS/CSHARP/asm-dude-vsix/BraceMatching/BraceMatchingTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/BraceMatching/BraceMatchingTagger.cs @@ -107,7 +107,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollec var open = from n in this._braceList where n.Value.Equals(lastText) select n.Key; - if (FindMatchingOpenChar(lastChar, (char)open.ElementAt(0), lastText, this._view.TextViewLines.Count, out pairSpan) == true) { + if (FindMatchingOpenChar(lastChar, open.ElementAt(0), lastText, this._view.TextViewLines.Count, out pairSpan) == true) { yield return new TagSpan(new SnapshotSpan(lastChar, 1), new TextMarkerTag("blue")); yield return new TagSpan(pairSpan, new TextMarkerTag("blue")); } diff --git a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionCommandFilter.cs b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionCommandFilter.cs index 90128db5..3a108c02 100644 --- a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionCommandFilter.cs +++ b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionCommandFilter.cs @@ -25,6 +25,7 @@ using Microsoft.VisualStudio; using Microsoft.VisualStudio.Language.Intellisense; using Microsoft.VisualStudio.OLE.Interop; +using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -68,6 +69,8 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv private int ExecMethod1(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { + ThreadHelper.ThrowIfNotOnUIThread(); + //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:Exec", this.ToString())); char typedChar = char.MinValue; @@ -142,6 +145,7 @@ private int ExecMethod1(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, I private int ExecMethod2(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { + ThreadHelper.ThrowIfNotOnUIThread(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:ExecMethod2", this.ToString())); bool handledChar = false; @@ -310,6 +314,7 @@ private void Filter() public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { + ThreadHelper.ThrowIfNotOnUIThread(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:QueryStatus", this.ToString())); if (pguidCmdGroup == VSConstants.VSStd2K) { diff --git a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs index cedc68bd..959192a8 100644 --- a/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs +++ b/VS/CSHARP/asm-dude-vsix/CodeCompletion/CodeCompletionSource.cs @@ -105,7 +105,7 @@ public void AugmentCompletionSession(ICompletionSession session, IList line.Start) && !AsmTools.AsmSourceTools.IsSeparatorChar((start - 1).GetChar())) + while ((start > line.Start) && !AsmSourceTools.IsSeparatorChar((start - 1).GetChar())) { start -= 1; } @@ -133,24 +133,24 @@ public void AugmentCompletionSession(ICompletionSession session, IList()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); + if (completions.Any()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); } else { { ISet selected1 = new HashSet { AsmTokenType.Directive, AsmTokenType.Jump, AsmTokenType.Misc, AsmTokenType.Mnemonic }; var completions1 = this.Selected_Completions(useCapitals, selected1, true); - if (completions1.Any()) completionSets.Add(new CompletionSet("All", "All", applicableTo, completions1, Enumerable.Empty())); + if (completions1.Any()) completionSets.Add(new CompletionSet("All", "All", applicableTo, completions1, Enumerable.Empty())); } if (false) { ISet selected2 = new HashSet { AsmTokenType.Jump, AsmTokenType.Mnemonic }; var completions2 = this.Selected_Completions(useCapitals, selected2, false); - if (completions2.Any()) completionSets.Add(new CompletionSet("Instr", "Instr", applicableTo, completions2, Enumerable.Empty())); + if (completions2.Any()) completionSets.Add(new CompletionSet("Instr", "Instr", applicableTo, completions2, Enumerable.Empty())); } if (false) { ISet selected3 = new HashSet { AsmTokenType.Directive, AsmTokenType.Misc }; var completions3 = this.Selected_Completions(useCapitals, selected3, true); - if (completions3.Any()) completionSets.Add(new CompletionSet("Directive", "Directive", applicableTo, completions3, Enumerable.Empty())); + if (completions3.Any()) completionSets.Add(new CompletionSet("Directive", "Directive", applicableTo, completions3, Enumerable.Empty())); } } } @@ -163,14 +163,14 @@ public void AugmentCompletionSession(ICompletionSession session, IList()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); + if (completions.Any()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); } else if (previousKeyword.Equals("SHORT") || previousKeyword.Equals("NEAR")) { // Suggest a label var completions = this.Label_Completions(useCapitals, false); - if (completions.Any()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); + if (completions.Any()) completionSets.Add(new CompletionSet("Labels", "Labels", applicableTo, completions, Enumerable.Empty())); } else { @@ -191,7 +191,7 @@ public void AugmentCompletionSession(ICompletionSession session, IList()) completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty())); + if (completions.Any()) completionSets.Add(new CompletionSet("All", "All", applicableTo, completions, Enumerable.Empty())); } } #endregion @@ -236,7 +236,7 @@ private IEnumerable Mnemonic_Operand_Completions(bool useCapitals, I //AsmDudeToolsStatic.Output_INFO("AsmCompletionSource:AugmentCompletionSession: keyword \"" + keyword + "\" is added to the completions list"); // by default, the entry.Key is with capitals - string insertionText = (useCapitals) ? keyword : keyword.ToLower(); + string insertionText = useCapitals ? keyword : keyword.ToLower(); string archStr = (arch == Arch.ARCH_NONE) ? "" : " [" + ArchTools.ToString(arch) + "]"; string descriptionStr = this._asmDudeTools.Get_Description(keyword); descriptionStr = (descriptionStr.Length == 0) ? "" : " - " + descriptionStr; @@ -278,7 +278,7 @@ private IEnumerable Mnemonic_Operand_Completions(bool useCapitals, I //AsmDudeToolsStatic.Output_INFO("AsmCompletionSource:AugmentCompletionSession: keyword \"" + keyword + "\" is added to the completions list"); // by default, the entry.Key is with capitals - string insertionText = (useCapitals) ? keyword2 : keyword2.ToLower(); + string insertionText = useCapitals ? keyword2 : keyword2.ToLower(); string archStr = (arch == Arch.ARCH_NONE) ? "" : " [" + ArchTools.ToString(arch) + "]"; string descriptionStr = this._asmDudeTools.Get_Description(keyword); descriptionStr = (descriptionStr.Length == 0) ? "" : " - " + descriptionStr; @@ -300,8 +300,8 @@ private IEnumerable Label_Completions(bool useCapitals, bool addSpec { if (addSpecialKeywords) { - yield return new Completion("SHORT", (useCapitals) ? "SHORT" : "short", null, this._icons[AsmTokenType.Misc], ""); - yield return new Completion("NEAR", (useCapitals) ? "NEAR" : "near", null, this._icons[AsmTokenType.Misc], ""); + yield return new Completion("SHORT", useCapitals ? "SHORT" : "short", null, this._icons[AsmTokenType.Misc], ""); + yield return new Completion("NEAR", useCapitals ? "NEAR" : "near", null, this._icons[AsmTokenType.Misc], ""); } ImageSource imageSource = this._icons[AsmTokenType.Label]; @@ -352,7 +352,7 @@ private IEnumerable Selected_Completions(bool useCapitals, ISet Selected_Completions(bool useCapitals, ISet private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { + AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: file={1}", this.ToString(), AsmDudeToolsStatic.GetFilename(this._textView.TextBuffer))); try { - //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: file=" + AsmDudeToolsStatic.GetFileName(this._textView.TextBuffer)); SnapshotPoint? point = this.GetMousePosition(new SnapshotPoint(this._textView.TextSnapshot, e.Position)); if (point.HasValue) { @@ -111,7 +111,7 @@ private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) if (this._session == null) { - AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: A: session was null, create a new session for triggerPoint " + pos + "; pos2=" + pos2); + AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: A: session was null, create a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); if (this._session != null) { @@ -125,7 +125,7 @@ private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { if (this._session.IsDismissed) { - AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: B: session was not null but was dismissed, create a new session for triggerPoint " + pos + "; pos2=" + pos2); + AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: B: session was not null but was dismissed, create a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); if (this._session != null) this._session.Dismissed += this._session_Dismissed; @@ -134,11 +134,11 @@ private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { if (this._session.ApplicableToSpan.GetSpan(this._textView.TextSnapshot).IntersectsWith(new Span(point.Value.Position, 0))) { - AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: C: session was not dismissed: intersects!"); + AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: C: session was not dismissed: intersects!", this.ToString())); } else { - AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: D: session was not dismissed but we need a new session for triggerPoint " + pos + "; pos2=" + pos2); + AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: D: session was not dismissed but we need a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); //if (this._session != null) this._session.Dismiss(); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); @@ -151,7 +151,7 @@ private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: Quickinfo for disassembly view", ToString())); System.Drawing.Point p = System.Windows.Forms.Control.MousePosition; - this.ToolTipLegacy(point.Value, new System.Windows.Point(p.X, p.Y)); + this.ToolTipLegacy(point.Value, new Point(p.X, p.Y)); } else { @@ -196,13 +196,13 @@ private Span Get_Keyword_Span_At_Point(SnapshotPoint triggerPoint) //1] find the start of the current keyword SnapshotPoint start = triggerPoint; - while ((start > line.Start) && !AsmTools.AsmSourceTools.IsSeparatorChar((start - 1).GetChar())) + while ((start > line.Start) && !AsmSourceTools.IsSeparatorChar((start - 1).GetChar())) { start -= 1; } //2] find the end of the current keyword SnapshotPoint end = triggerPoint; - while (((end + 1) < line.End) && !AsmTools.AsmSourceTools.IsSeparatorChar((end + 1).GetChar())) + while (((end + 1) < line.End) && !AsmSourceTools.IsSeparatorChar((end + 1).GetChar())) { end += 1; } @@ -217,7 +217,7 @@ public void CloseToolTip() this._session = null; } - private void ToolTipLegacy(SnapshotPoint triggerPoint, System.Windows.Point p) + private void ToolTipLegacy(SnapshotPoint triggerPoint, Point p) { var span = this.Get_Keyword_Span_At_Point(triggerPoint); ITrackingSpan applicableTo = this._textView.TextSnapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive); @@ -234,7 +234,7 @@ private void ToolTipLegacy(SnapshotPoint triggerPoint, System.Windows.Point p) Mnemonic mnemonic = AsmSourceTools.ParseMnemonic(keyword, false); if (mnemonic != Mnemonic.NONE) { - var instructionTooltipWindow = new InstructionTooltipWindow(AsmDudeToolsStatic.Get_Font_Color_Async().Result) + var instructionTooltipWindow = new InstructionTooltipWindow(AsmDudeToolsStatic.GetFontColor()) { Owner = this // set the owner of this windows such that we can manually close this window }; @@ -247,7 +247,7 @@ private void ToolTipLegacy(SnapshotPoint triggerPoint, System.Windows.Point p) BorderBrush = System.Windows.Media.Brushes.LightGray, BorderThickness = new Thickness(1.0), CornerRadius = new CornerRadius(2.0), - Background = AsmDudeToolsStatic.Get_Background_Color_Async().Result, + Background = AsmDudeToolsStatic.GetBackgroundColor(), Child = instructionTooltipWindow }; diff --git a/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSource.cs b/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSource.cs index 80353aa1..2e71d19f 100644 --- a/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSource.cs +++ b/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSource.cs @@ -118,7 +118,7 @@ private void Handle(IQuickInfoSession session, IList quickInfoContent, o return; } - Brush foreground = AsmDudeToolsStatic.Get_Font_Color_Async().Result; + Brush foreground = AsmDudeToolsStatic.GetFontColor(); var enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator(); if (enumerator.MoveNext()) @@ -281,7 +281,7 @@ private void Handle(IQuickInfoSession session, IList quickInfoContent, o description.Inlines.Add(Make_Run1("Constant ", foreground)); var (Valid, Value, NBits) = AsmSourceTools.Evaluate_Constant(keyword); - string constantStr = (Valid) + string constantStr = Valid ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b" : keyword; @@ -346,8 +346,8 @@ private void Handle(IQuickInfoSession session, IList quickInfoContent, o } if (description != null) { - description.FontSize = AsmDudeToolsStatic.Get_Font_Size_Async().Result + 2; - description.FontFamily = AsmDudeToolsStatic.Get_Font_Type_Async().Result; + description.FontSize = AsmDudeToolsStatic.GetFontSize() + 2; + description.FontFamily = AsmDudeToolsStatic.GetFontType(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } diff --git a/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSourceProvider.cs b/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSourceProvider.cs index d25d3d7b..e0857edc 100644 --- a/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSourceProvider.cs +++ b/VS/CSHARP/asm-dude-vsix/QuickInfo/AsmQuickInfoSourceProvider.cs @@ -52,11 +52,12 @@ internal sealed class AsmQuickInfoSourceProvider : IQuickInfoSourceProvider public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer buffer) { - Func sc = delegate () { + AsmQuickInfoSource sc() + { var labelGraph = AsmDudeToolsStatic.GetOrCreate_Label_Graph(buffer, this._aggregatorFactory, this._docFactory, this._contentService); var asmSimulator = AsmSimulator.GetOrCreate_AsmSimulator(buffer, this._aggregatorFactory); return new AsmQuickInfoSource(buffer, this._aggregatorFactory, labelGraph, asmSimulator); - }; + } return buffer.Properties.GetOrCreateSingletonProperty(sc); } } diff --git a/VS/CSHARP/asm-dude-vsix/QuickInfo/InstructionTooltipWindow.xaml.cs b/VS/CSHARP/asm-dude-vsix/QuickInfo/InstructionTooltipWindow.xaml.cs index e78ec238..1554c97e 100644 --- a/VS/CSHARP/asm-dude-vsix/QuickInfo/InstructionTooltipWindow.xaml.cs +++ b/VS/CSHARP/asm-dude-vsix/QuickInfo/InstructionTooltipWindow.xaml.cs @@ -30,6 +30,7 @@ using AsmDude.Tools; using AsmTools; using Microsoft.VisualStudio.Language.Intellisense; +using Microsoft.VisualStudio.Shell; namespace AsmDude.QuickInfo { @@ -90,7 +91,7 @@ public void SetDescription(Mnemonic mnemonic, AsmDudeTools asmDudeTools) string mnemonicStr = mnemonic.ToString(); this.Description.Inlines.Add(new Run("Mnemonic ") { FontWeight = FontWeights.Bold, Foreground = this._foreground }); - this.Description.Inlines.Add(new Run(mnemonicStr) { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(AsmDudeToolsStatic.ConvertColor((AsmSourceTools.IsJump(mnemonic) ? Settings.Default.SyntaxHighlighting_Jump : Settings.Default.SyntaxHighlighting_Opcode))) }); + this.Description.Inlines.Add(new Run(mnemonicStr) { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(AsmSourceTools.IsJump(mnemonic) ? Settings.Default.SyntaxHighlighting_Jump : Settings.Default.SyntaxHighlighting_Opcode)) }); string archStr = ":" + ArchTools.ToString(asmDudeTools.Mnemonic_Store.GetArch(mnemonic)) + " "; string descr = asmDudeTools.Mnemonic_Store.GetDescription(mnemonic); @@ -147,8 +148,8 @@ public void SetPerformanceInfo(Mnemonic mnemonic, AsmDudeTools asmDudeTools) Foreground = this._foreground }); } - this.PerformanceExpander.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; - this.PerformanceBorder.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; + this.PerformanceExpander.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; + this.PerformanceBorder.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; } } @@ -201,8 +202,8 @@ public void SetAsmSim(AsmSimulator asmSimulator, int lineNumber, bool isExpanded } } - this.AsmSimGridExpander.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; - this.AsmSimGridBorder.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; + this.AsmSimGridExpander.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; + this.AsmSimGridBorder.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; this.AsmSimGridExpanderNumeration.SelectionChanged += (sender, i) => { @@ -260,7 +261,7 @@ private void Generate(Rn reg, bool isBefore, int row) { FontFamily f = new FontFamily("Consolas"); - int column = (isBefore) ? 0 : 1; + int column = isBefore ? 0 : 1; { var textBox = new TextBox() { @@ -291,7 +292,8 @@ private void Generate(Rn reg, bool isBefore, int row) this.AsmSimGrid.Children.Add(button); Grid.SetRow(button, row); Grid.SetColumn(button, column); - button.Click += (sender, e) => { this.Update_Async(sender as Button); }; + //TODO: is the following Event handler ever unsubscribed? + button.Click += (sender, e) => this.Update_Async(sender as Button).ConfigureAwait(false); } else { @@ -305,7 +307,7 @@ private void Generate(Flags flag, bool isBefore, int row) { FontFamily f = new FontFamily("Consolas"); - int column = (isBefore) ? 0 : 1; + int column = isBefore ? 0 : 1; { var textBlock = new TextBox() { @@ -334,7 +336,7 @@ private void Generate(Flags flag, bool isBefore, int row) this.AsmSimGrid.Children.Add(button); Grid.SetRow(button, row); Grid.SetColumn(button, column); - button.Click += (sender, e) => { this.Update_Async(sender as Button); }; + button.Click += (sender, e) => this.Update_Async(sender as Button).ConfigureAwait(false); } else { @@ -344,34 +346,28 @@ private void Generate(Flags flag, bool isBefore, int row) } } - private async void Update_Async(Button button) + private async System.Threading.Tasks.Task Update_Async(Button button) { - await System.Threading.Tasks.Task.Run(() => + if (button == null) return; + if (this._asmSimulator == null) return; + + try { - try - { - if (button == null) return; - if (this._asmSimulator == null) return; - this.Dispatcher.Invoke((Action)(() => - { - ButtonInfo info = (ButtonInfo)button.Tag; - if (info.reg == Rn.NOREG) - { - info.text.Text = info.flag.ToString() + " = " + this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before); - } - else - { - info.text.Text = info.reg.ToString() + " = " + this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration)); - } - info.text.Visibility = Visibility.Visible; - button.Visibility = Visibility.Collapsed; - })); - } - catch (Exception e) - { - AsmDudeToolsStatic.Output_ERROR("InstructionTooltipWindow: Update_Async: e=" + e.ToString()); - } - }); + if (!ThreadHelper.CheckAccess()) + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + + ButtonInfo info = (ButtonInfo)button.Tag; + info.text.Text = (info.reg == Rn.NOREG) + ? info.flag.ToString() + " = " + this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before) + : info.reg.ToString() + " = " + this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration)); + + info.text.Visibility = Visibility.Visible; + button.Visibility = Visibility.Collapsed; + } + catch (Exception e) + { + AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_Async; e={1}", this.ToString(), e.ToString())); + }; } } } diff --git a/VS/CSHARP/asm-dude-vsix/QuickInfo/RegisterTooltipWindow.xaml.cs b/VS/CSHARP/asm-dude-vsix/QuickInfo/RegisterTooltipWindow.xaml.cs index 15f6367e..af213293 100644 --- a/VS/CSHARP/asm-dude-vsix/QuickInfo/RegisterTooltipWindow.xaml.cs +++ b/VS/CSHARP/asm-dude-vsix/QuickInfo/RegisterTooltipWindow.xaml.cs @@ -28,6 +28,7 @@ using AsmTools; using AsmDude.Tools; +using Microsoft.VisualStudio.Shell; namespace AsmDude.QuickInfo { @@ -83,8 +84,8 @@ public void SetAsmSim(AsmSimulator asmSimulator, Rn reg, int lineNumber, bool is empty = false; } - this.AsmSimGridExpander.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; - this.AsmSimGridBorder.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; + this.AsmSimGridExpander.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; + this.AsmSimGridBorder.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; this.AsmSimGridExpanderNumeration.SelectionChanged += (sender, i) => { @@ -105,10 +106,10 @@ private void Generate(bool isBefore, Rn reg) { FontFamily f = new FontFamily("Consolas"); - int row = (isBefore) ? 1 : 2; + int row = isBefore ? 1 : 2; { var textBlock = new TextBlock() { - Text = (isBefore) ? "Before:" : "After:", + Text = isBefore ? "Before:" : "After:", FontFamily = f, Foreground = this._foreground }; @@ -151,7 +152,7 @@ private void Generate(bool isBefore, Rn reg) this.AsmSimGrid.Children.Add(button); Grid.SetRow(button, row); Grid.SetColumn(button, 1); - button.Click += (sender, e) => { this.Update_Async(sender as Button); }; + button.Click += (sender, e) => this.Update_Async(sender as Button).ConfigureAwait(false); } else { @@ -161,31 +162,29 @@ private void Generate(bool isBefore, Rn reg) } } - private async void Update_Async(Button button) + private async System.Threading.Tasks.Task Update_Async(Button button) { - await System.Threading.Tasks.Task.Run(() => + if (button == null) return; + if (this._asmSimulator == null) return; + + try { - try - { - if (button == null) return; - if (this._asmSimulator == null) return; - this.Dispatcher.Invoke((Action)(() => - { - ButtonInfo info = (ButtonInfo)button.Tag; + if (!ThreadHelper.CheckAccess()) + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - info.text.Text = (info.reg == Rn.NOREG) - ? this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before) - : this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(this.AsmSimGridExpanderNumeration.Text)); + ButtonInfo info = (ButtonInfo)button.Tag; - info.text.Visibility = Visibility.Visible; - button.Visibility = Visibility.Collapsed; - })); - } - catch (Exception e) - { - AsmDudeToolsStatic.Output_ERROR("RegisterTooltipWindow: Update_Async: e=" + e.ToString()); - } - }); + info.text.Text = (info.reg == Rn.NOREG) + ? this._asmSimulator.Get_Flag_Value_and_Block(info.flag, this._lineNumber, info.before) + : this._asmSimulator.Get_Register_Value_and_Block(info.reg, this._lineNumber, info.before, AsmSourceTools.ParseNumeration(this.AsmSimGridExpanderNumeration.Text)); + + info.text.Visibility = Visibility.Visible; + button.Visibility = Visibility.Collapsed; + } + catch (Exception e) + { + AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_Async; e={1}", this.ToString(), e.ToString())); + } } } } diff --git a/VS/CSHARP/asm-dude-vsix/Settings.Designer.cs b/VS/CSHARP/asm-dude-vsix/Settings.Designer.cs index a391a7b4..71a2456c 100644 --- a/VS/CSHARP/asm-dude-vsix/Settings.Designer.cs +++ b/VS/CSHARP/asm-dude-vsix/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace AsmDude { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/VS/CSHARP/asm-dude-vsix/Squiggles/SquigglesTagger.cs b/VS/CSHARP/asm-dude-vsix/Squiggles/SquigglesTagger.cs index cc02bfb4..c80ea9db 100644 --- a/VS/CSHARP/asm-dude-vsix/Squiggles/SquigglesTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/Squiggles/SquigglesTagger.cs @@ -63,13 +63,12 @@ internal SquigglesTagger( this._sourceBuffer = buffer; this._aggregator = AsmDudeToolsStatic.GetOrCreate_Aggregator(buffer, aggregatorFactory); this._errorListProvider = AsmDudeTools.Instance.Error_List_Provider; - this._foreground = AsmDudeToolsStatic.Get_Font_Color_Async().Result; + this._foreground = AsmDudeToolsStatic.GetFontColor(); this._labelGraph = labelGraph; if (this._labelGraph.Enabled) { - this._labelGraph.Reset_Done_Event += (o, i) => - { + this._labelGraph.Reset_Done_Event += (o, i) => { this.Update_Squiggles_Tasks_Async().ConfigureAwait(false); this.Update_Error_Tasks_Labels_Async().ConfigureAwait(false); }; @@ -525,7 +524,7 @@ await System.Threading.Tasks.Task.Run(() => Column = this.Get_Keyword_Begin_End(lineContent, keyword), Text = "Syntax Error: " + message, ErrorCategory = TaskErrorCategory.Error, - Document = AsmDudeToolsStatic.Get_Filename_Async(this._sourceBuffer).Result + Document = AsmDudeToolsStatic.GetFilenameAsync(this._sourceBuffer).Result }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; this._errorListProvider.Tasks.Add(errorTask); @@ -551,7 +550,7 @@ await System.Threading.Tasks.Task.Run(() => Column = this.Get_Keyword_Begin_End(lineContent, keyword), Text = "Semantic Warning: " + message, ErrorCategory = TaskErrorCategory.Warning, - Document = AsmDudeToolsStatic.Get_Filename_Async(this._sourceBuffer).Result + Document = AsmDudeToolsStatic.GetFilenameAsync(this._sourceBuffer).Result }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; this._errorListProvider.Tasks.Add(errorTask); @@ -577,7 +576,7 @@ await System.Threading.Tasks.Task.Run(() => Column = this.Get_Keyword_Begin_End(lineContent, keyword), Text = "Semantic Warning: " + message, ErrorCategory = TaskErrorCategory.Warning, - Document = AsmDudeToolsStatic.Get_Filename_Async(this._sourceBuffer).Result + Document = AsmDudeToolsStatic.GetFilenameAsync(this._sourceBuffer).Result }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; this._errorListProvider.Tasks.Add(errorTask); @@ -603,7 +602,7 @@ await System.Threading.Tasks.Task.Run(() => Column = this.Get_Keyword_Begin_End(lineContent, keyword), Text = "Semantic Warning: " + message, ErrorCategory = TaskErrorCategory.Warning, - Document = AsmDudeToolsStatic.Get_Filename_Async(this._sourceBuffer).Result + Document = AsmDudeToolsStatic.GetFilenameAsync(this._sourceBuffer).Result }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; this._errorListProvider.Tasks.Add(errorTask); diff --git a/VS/CSHARP/asm-dude-vsix/Tools/AsmDudeToolsStatic.cs b/VS/CSHARP/asm-dude-vsix/Tools/AsmDudeToolsStatic.cs index 553a3078..70b8cd94 100644 --- a/VS/CSHARP/asm-dude-vsix/Tools/AsmDudeToolsStatic.cs +++ b/VS/CSHARP/asm-dude-vsix/Tools/AsmDudeToolsStatic.cs @@ -34,15 +34,19 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Windows.Media.Imaging; -using Task = Microsoft.VisualStudio.Shell.Task; +//using Task = Microsoft.VisualStudio.Shell.Task; + namespace AsmDude.Tools { public static class AsmDudeToolsStatic { + private static bool first_log_message = true; + #region Singleton Factories public static ITagAggregator GetOrCreate_Aggregator( @@ -117,10 +121,18 @@ public static AssemblerEnum Used_Assembler } } + public static string GetFilename(ITextBuffer buffer) + { + return ThreadHelper.JoinableTaskFactory.Run(async delegate + { + return await GetFilenameAsync(buffer); + }); + } + /// /// get the full filename (with path) of the provided buffer; returns null if such name does not exist /// - public static async Task Get_Filename_Async(ITextBuffer buffer) + public static async Task GetFilenameAsync(ITextBuffer buffer) { if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -140,7 +152,15 @@ public static async System.Threading.Tasks.Task Open_Disassembler_Async() dte.ExecuteCommand("Debug.Disassembly"); } - public static async Task Get_Font_Size_Async() + public static int GetFontSize() + { + return ThreadHelper.JoinableTaskFactory.Run(async delegate + { + return await GetFontSizeAsync(); + }); + } + + public static async Task GetFontSizeAsync() { if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -152,8 +172,16 @@ public static async Task Get_Font_Size_Async() return fontSize; } - public static async Task Get_Font_Type_Async() + public static FontFamily GetFontType() + { + return ThreadHelper.JoinableTaskFactory.Run(async delegate { + return await GetFontTypeAsync(); + }); + } + + public static async Task GetFontTypeAsync() { + await System.Threading.Tasks.Task.Yield(); if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -165,7 +193,15 @@ public static async Task Get_Font_Type_Async() return new FontFamily(font); } - public static async Task Get_Font_Color_Async() + public static Brush GetFontColor() + { + return ThreadHelper.JoinableTaskFactory.Run(async delegate + { + return await GetFontColorAsync(); + }); + } + + public static async Task GetFontColorAsync() { if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -188,7 +224,15 @@ public static async Task Get_Font_Color_Async() return new SolidColorBrush(Colors.Gray); } - public static async Task Get_Background_Color_Async() + public static Brush GetBackgroundColor() + { + return ThreadHelper.JoinableTaskFactory.Run(async delegate + { + return await GetBackgroundColorAsync(); + }); + } + + public static async Task GetBackgroundColorAsync() { if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -216,7 +260,7 @@ public static async void Error_Task_Navigate_Handler(object sender, EventArgs ar if (!ThreadHelper.CheckAccess()) await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - Task task = sender as Task; + var task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { @@ -371,6 +415,23 @@ public static async System.Threading.Tasks.Task OutputAsync(string msg) IVsOutputWindowPane outputPane = await GetOutputPaneAsync(); string msg2 = string.Format(CultureInfo.CurrentCulture, "{0}", msg.Trim() + Environment.NewLine); + + if (first_log_message) + { + first_log_message = false; + + StringBuilder sb = new StringBuilder(); + sb.Append("Welcome to\n"); + sb.Append(" _____ ____ _ \n"); + sb.Append("| _ |___ _____ | \\ _ _ _| |___ \n"); + sb.Append("| |_ -| | | | | | | . | -_|\n"); + sb.Append("|__|__|___|_|_|_| |____/|___|___|___|\n"); + sb.Append("INFO: Loaded AsmDude version " + typeof(AsmDudePackage).Assembly.GetName().Version + " (" + ApplicationInformation.CompileDate.ToString() + ")\n"); + sb.Append("INFO: Open source assembly extension. Making programming in assembler almost bearable.\n"); + sb.Append("INFO: More info at https://github.com/HJLebbink/asm-dude \n"); + sb.Append("----------------------------------\n"); + msg2 = sb.ToString() + msg2; + } if (outputPane == null) { Debug.Write(msg2); @@ -458,7 +519,7 @@ public static void Disable_Message(string msg, string filename, ErrorListProvide for (int i = 0; i < errorListProvider.Tasks.Count; ++i) { - Task t = errorListProvider.Tasks[i]; + var t = errorListProvider.Tasks[i]; if (t.Text.Equals(msg)) { return; diff --git a/VS/CSHARP/asm-dude-vsix/Tools/AsmSimulator.cs b/VS/CSHARP/asm-dude-vsix/Tools/AsmSimulator.cs index 07c0ec09..c85087a3 100644 --- a/VS/CSHARP/asm-dude-vsix/Tools/AsmSimulator.cs +++ b/VS/CSHARP/asm-dude-vsix/Tools/AsmSimulator.cs @@ -67,8 +67,8 @@ public sealed class AsmSimulator : IDisposable private readonly Delay _delay; private int _last_Changed_LineNumber = 0; - private object _resetLock = new object(); - private object _updateLock = new object(); + private readonly object _resetLock = new object(); + private readonly object _updateLock = new object(); #endregion #region Constuctors diff --git a/VS/CSHARP/asm-dude-vsix/Tools/LabelGraph.cs b/VS/CSHARP/asm-dude-vsix/Tools/LabelGraph.cs index 02d96f69..a5c65e2c 100644 --- a/VS/CSHARP/asm-dude-vsix/Tools/LabelGraph.cs +++ b/VS/CSHARP/asm-dude-vsix/Tools/LabelGraph.cs @@ -74,7 +74,7 @@ public sealed class LabelGraph private readonly Delay _delay; private bool _bussy = false; private IWorkItemResult _thread_Result; - private object _updateLock = new object(); + private readonly object _updateLock = new object(); #endregion Private Fields #region Constructor @@ -101,7 +101,7 @@ public LabelGraph( this._hasLabel = new HashSet(); this._hasDef = new HashSet(); this._undefined_includes = new List<(string Include_Filename, string Path, string Source_Filename, int LineNumber)>(); - this._thisFilename = AsmDudeToolsStatic.Get_Filename_Async(this._buffer).Result; + this._thisFilename = AsmDudeToolsStatic.GetFilename(this._buffer); this._delay = new Delay(AsmDudePackage.msSleepBeforeAsyncExecution, 100, AsmDudeTools.Instance.Thread_Pool); this.Enabled = Settings.Default.IntelliSense_Label_Analysis_On; @@ -330,7 +330,7 @@ private void Reset_Private() this._hasLabel.Clear(); this._hasDef.Clear(); this._filenames.Clear(); - this._filenames.Add(0, AsmDudeToolsStatic.Get_Filename_Async(this._buffer).Result); + this._filenames.Add(0, AsmDudeToolsStatic.GetFilename(this._buffer)); this._undefined_includes.Clear(); const uint fileId = 0; // use fileId=0 for the main file (and use numbers higher than 0 for included files) @@ -378,7 +378,7 @@ private void Disable() AsmDudeToolsStatic.Disable_Message(msg, this._thisFilename, this.Error_List_Provider); } - private static int Get_Line_Number(IMappingTagSpan tag) + private static int Get_Line_Number_UNUSED(IMappingTagSpan tag) { return AsmDudeToolsStatic.Get_LineNumber(tag.Span.GetSpans(tag.Span.AnchorBuffer)[0]); } diff --git a/VS/CSHARP/asm-dude-vsix/app.config b/VS/CSHARP/asm-dude-vsix/app.config index c5ea98e5..1755a080 100644 --- a/VS/CSHARP/asm-dude-vsix/app.config +++ b/VS/CSHARP/asm-dude-vsix/app.config @@ -1,587 +1,584 @@ - + -
+
- - Blue - - - DarkRed - - - Green - - - Magenta - - - Blue - - - OrangeRed - - - Chocolate - - - DarkOrange - - - True - - - True - - - #region - - - #endregion - - - True - - - https://github.com/HJLebbink/asm-dude/wiki/ - - - True - - - True - - - Yellow - - - True - - - True - - - False - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - False - - - True - - - True - - - True - - - True - - - True - - - True - - - False - - - False - - - True - - - True - - - True - - - False - - - True - - - True - - - False - - - True - - - True - - - True - - - True - - - True - - - True - - - False - - - True - - - True - - - False - - - True - - - False - - - False - - - False - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - False - - - False - - - True - - - False - - - False - - - True - - - False - - - True - - - True - - - True - - - True - - - False - - - True - - - True - - - Red - - - False - - - False - - - False - - - False - - - False - - - False - - - True - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - True - - - False - - - False - - - False - - - False - - - False - - - True - - - Silver - - - Silver - - - Silver - - - 50 - - - False - - - False - - - False - - - False - - - True - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - True - - - False - - - 3 - - - False - - - False - - - #pragma assume - - - True - - - True - - - HEX - - - HEX - - - HEX - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - False - - - True - - - False - - - True - - - False - - - False - - - False - - - False - - - False - - - False - - + + Blue + + + DarkRed + + + Green + + + Magenta + + + Blue + + + OrangeRed + + + Chocolate + + + DarkOrange + + + True + + + True + + + #region + + + #endregion + + + True + + + https://github.com/HJLebbink/asm-dude/wiki/ + + + True + + + True + + + Yellow + + + True + + + True + + + False + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + False + + + True + + + True + + + True + + + True + + + True + + + True + + + False + + + False + + + True + + + True + + + True + + + False + + + True + + + True + + + False + + + True + + + True + + + True + + + True + + + True + + + True + + + False + + + True + + + True + + + False + + + True + + + False + + + False + + + False + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + False + + + False + + + True + + + False + + + False + + + True + + + False + + + True + + + True + + + True + + + True + + + False + + + True + + + True + + + Red + + + False + + + False + + + False + + + False + + + False + + + False + + + True + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + True + + + False + + + False + + + False + + + False + + + False + + + True + + + Silver + + + Silver + + + Silver + + + 50 + + + False + + + False + + + False + + + False + + + True + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + True + + + False + + + 3 + + + False + + + False + + + #pragma assume + + + True + + + True + + + HEX + + + HEX + + + HEX + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + False + + + True + + + False + + + True + + + False + + + False + + + False + + + False + + + False + + + False + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VS/CSHARP/asm-dude-vsix/asm-dude-vsix.csproj b/VS/CSHARP/asm-dude-vsix/asm-dude-vsix.csproj index 95a0b3ab..359eb189 100644 --- a/VS/CSHARP/asm-dude-vsix/asm-dude-vsix.csproj +++ b/VS/CSHARP/asm-dude-vsix/asm-dude-vsix.csproj @@ -1,7 +1,7 @@  - + - 15.0 + 16.0 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -24,6 +24,9 @@ true + + + 14.0 AsmDudePackage.ico @@ -324,11 +327,14 @@ 10.0.3 - 3.3.0 + 3.4.0 0.0.1 + + 1.2.0-beta2 + 4.5.0 @@ -341,6 +347,9 @@ 14.3.25407 + + 15.8.36 + 14.3.25407 @@ -353,8 +362,13 @@ 14.3.25407 + + 16.0.96-beta + 4.0.0.1 + MSBuild:Compile + Designer 3.6.61119.7 @@ -362,6 +376,9 @@ 2.2.4 + + 1.2.0-beta2 + 4.5.0 @@ -373,6 +390,7 @@ + diff --git a/VS/CSHARP/asm-irony/Example.cs b/VS/CSHARP/asm-irony/Example.cs index 602da3ce..94cf3e80 100644 --- a/VS/CSHARP/asm-irony/Example.cs +++ b/VS/CSHARP/asm-irony/Example.cs @@ -219,7 +219,7 @@ private void findTimesChar(ParsingContext context, CustomParserAction customActi string currentStr = context.CurrentParserInput.Term.Name; Debug.WriteLine("findTimesChar: current Term = " + currentStr); - if (context.CurrentParserInput.Term == base.Eof) { + if (context.CurrentParserInput.Term == Eof) { return; } var scanner = context.Parser.Scanner; diff --git a/VS/CSHARP/asm-irony/Example2.cs b/VS/CSHARP/asm-irony/Example2.cs index fd2a643a..06bd4a39 100644 --- a/VS/CSHARP/asm-irony/Example2.cs +++ b/VS/CSHARP/asm-irony/Example2.cs @@ -49,7 +49,7 @@ private void findTimesChar(ParsingContext context, CustomParserAction customActi string currentStr = context.CurrentParserInput.Term.Name; Debug.WriteLine("findTimesChar: current Term = " + currentStr); - if (context.CurrentParserInput.Term == base.Eof) { + if (context.CurrentParserInput.Term == Eof) { return; } var scanner = context.Parser.Scanner; diff --git a/VS/CSHARP/asm-sim-lib/BitOperations.cs b/VS/CSHARP/asm-sim-lib/BitOperations.cs index 7472326e..b75d656a 100644 --- a/VS/CSHARP/asm-sim-lib/BitOperations.cs +++ b/VS/CSHARP/asm-sim-lib/BitOperations.cs @@ -35,7 +35,7 @@ public static (BitVecExpr result, BoolExpr cf, BoolExpr of, BoolExpr af) Neg( ) { BitVecExpr zero = ctx.MkBV(0, a.SortSize); - return BitOperations.Substract(zero, a, ctx); + return Substract(zero, a, ctx); } #endregion diff --git a/VS/CSHARP/asm-sim-lib/BranchInfo.cs b/VS/CSHARP/asm-sim-lib/BranchInfo.cs index 02311f36..4e2de345 100644 --- a/VS/CSHARP/asm-sim-lib/BranchInfo.cs +++ b/VS/CSHARP/asm-sim-lib/BranchInfo.cs @@ -47,11 +47,11 @@ public BoolExpr GetData(Context ctx) if (false) { BoolExpr bc = this.BranchCondition.Translate(ctx) as BoolExpr; - return (this.BranchTaken) ? bc : ctx.MkNot(bc); + return this.BranchTaken ? bc : ctx.MkNot(bc); } else { - return (this.BranchTaken) ? this.BranchCondition : ctx.MkNot(this.BranchCondition); + return this.BranchTaken ? this.BranchCondition : ctx.MkNot(this.BranchCondition); } } public override string ToString() diff --git a/VS/CSHARP/asm-sim-lib/DynamicFlow.cs b/VS/CSHARP/asm-sim-lib/DynamicFlow.cs index 4c7f5d65..3aa2d1f0 100644 --- a/VS/CSHARP/asm-sim-lib/DynamicFlow.cs +++ b/VS/CSHARP/asm-sim-lib/DynamicFlow.cs @@ -144,7 +144,7 @@ private bool Has_Edge(string source, string target, bool isBranch) { if (this._graph.TryGetEdge(source, target, out var tag)) { - return (tag.Tag.Branch == isBranch); + return tag.Tag.Branch == isBranch; } return false; } @@ -156,7 +156,7 @@ public bool Has_LineNumber(int lineNumber) public int LineNumber(string key) { - return (this._key_2_LineNumber.TryGetValue(key, out var v)) ? v : -1; + return this._key_2_LineNumber.TryGetValue(key, out var v) ? v : -1; } public IEnumerable Create_States_Before(int lineNumber) @@ -212,7 +212,7 @@ public State Create_State_Before(string key) private bool Has_Branch(int lineNumber) { string key = this._lineNumber_2_Key[lineNumber]; - return (this._graph.OutDegree(key) > 1); + return this._graph.OutDegree(key) > 1; } public BoolExpr Get_Branch_Condition(int lineNumber) @@ -521,7 +521,7 @@ private void ToString(string key, StaticFlow sFlow, ref StringBuilder sb) Debug.Assert(v.Source == key); string nextKey = v.Target; sb.AppendLine("------------------------------------------"); - sb.AppendLine("Transition from state " + key + " to " + nextKey + "; execute LINE " + lineNumber + ": \"" + codeLine + "\" " + ((v.Tag.Branch) ? "[Forward Branching]" : "[Forward Continue]")); + sb.AppendLine("Transition from state " + key + " to " + nextKey + "; execute LINE " + lineNumber + ": \"" + codeLine + "\" " + (v.Tag.Branch ? "[Forward Branching]" : "[Forward Continue]")); this.ToString(nextKey, sFlow, ref sb); } } diff --git a/VS/CSHARP/asm-sim-lib/GraphTools.cs b/VS/CSHARP/asm-sim-lib/GraphTools.cs index ef17883e..d11a51de 100644 --- a/VS/CSHARP/asm-sim-lib/GraphTools.cs +++ b/VS/CSHARP/asm-sim-lib/GraphTools.cs @@ -102,7 +102,7 @@ public static IEnumerable Get_First_Mutual_Branch_Point_Backwards(string foreach (var v in Get_First_Branch_Point_Backwards(s1, graph)) branchPoints1.Add(v); foreach (var v in Get_First_Branch_Point_Backwards(s2, graph)) branchPoints2.Add(v); - foreach (string mutual in branchPoints1.Intersect(branchPoints2)) + foreach (string mutual in branchPoints1.Intersect(branchPoints2)) { yield return mutual; } @@ -128,7 +128,7 @@ public static string Get_Branch_Point(string vertex1, string vertex2, Bidirectio foreach (var v in Get_Branch_Points_Backwards(vertex1, graph)) branchPoints1.Add(v); foreach (var v in Get_Branch_Points_Backwards(vertex2, graph)) branchPoints2.Add(v); - var m = new List(branchPoints1.Intersect(branchPoints2)); + var m = new List(branchPoints1.Intersect(branchPoints2)); switch (m.Count) { case 0: diff --git a/VS/CSHARP/asm-sim-lib/Mnemonics.cs b/VS/CSHARP/asm-sim-lib/Mnemonics.cs index c04c1839..7fe9275f 100644 --- a/VS/CSHARP/asm-sim-lib/Mnemonics.cs +++ b/VS/CSHARP/asm-sim-lib/Mnemonics.cs @@ -271,7 +271,7 @@ protected static IEnumerable ReadRegs(Operand op1, bool op1_IsWrite) if (BaseReg != Rn.NOREG) yield return BaseReg; if (IndexReg != Rn.NOREG) yield return IndexReg; } - if ((!op1_IsWrite) && (op1.IsReg)) + if ((!op1_IsWrite) && op1.IsReg) { yield return op1.Rn; } @@ -293,7 +293,7 @@ protected static IEnumerable ReadRegs(Operand op1, bool op1_IsWrite, Operand protected static IEnumerable WriteRegs(Operand op1) { - if ((op1 != null) && (op1.IsReg)) yield return op1.Rn; + if ((op1 != null) && op1.IsReg) yield return op1.Rn; } protected static IEnumerable WriteRegs(Operand op1, Operand op2) @@ -370,7 +370,7 @@ public Opcode1Base(Mnemonic mnemonic, string[] args, Ot1 allowedOperands1, (stri this.SyntaxError = string.Format("\"{0}\": First operand ({1}) cannot be of type {2}. Allowed types: {3}.", this.ToString(), this.op1, this.op1.Type, AsmSourceTools.ToString(allowedOperands1)); } } - public BitVecExpr Op1Value { get { return OpcodeBase.OpValue(this.op1, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op1Value { get { return OpValue(this.op1, this.keys.PrevKey, this._ctx); } } public override bool MemReadStatic { get { return this.ToMemReadWrite(this.op1); } } public override bool MemWriteStatic { get { return this.ToMemReadWrite(this.op1); } } } @@ -410,8 +410,8 @@ public Opcode2Base(Mnemonic mnemonic, string[] args, Ot2 allowedOperands2, (stri this.ToString(), this.op1, this.op1.Type, this.op1.NBits, this.op2, this.op2.Type, this.op2.NBits, AsmSourceTools.ToString(allowedOperands2)); } } - public BitVecExpr Op1Value { get { return OpcodeBase.OpValue(this.op1, this.keys.PrevKey, this._ctx); } } - public BitVecExpr Op2Value { get { return OpcodeBase.OpValue(this.op2, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op1Value { get { return OpValue(this.op1, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op2Value { get { return OpValue(this.op2, this.keys.PrevKey, this._ctx); } } public override bool MemReadStatic { get { return this.ToMemReadWrite(this.op1, this.op2); } } public override bool MemWriteStatic { get { return this.ToMemReadWrite(this.op1, this.op2); } } } @@ -453,9 +453,9 @@ public Opcode3Base(Mnemonic mnemonic, string[] args, Ot3 allowedOperands3, (stri this.SyntaxError = string.Format("\"{0}\": Operand1={1} ({2}, bits={3}); Operand2={4} ({5}, bits={6}); op3={6} ({7}, bits={8}) Allowed types: {9}.", this.ToString(), this.op1, this.op1.Type, this.op1.NBits, this.op2, this.op2.Type, this.op2.NBits, this.op3, this.op3.Type, this.op3.NBits, AsmSourceTools.ToString(allowedOperands3)); } } - public BitVecExpr Op1Value { get { return OpcodeBase.OpValue(this.op1, this.keys.PrevKey, this._ctx); } } - public BitVecExpr Op2Value { get { return OpcodeBase.OpValue(this.op2, this.keys.PrevKey, this._ctx); } } - public BitVecExpr Op3Value { get { return OpcodeBase.OpValue(this.op3, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op1Value { get { return OpValue(this.op1, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op2Value { get { return OpValue(this.op2, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op3Value { get { return OpValue(this.op3, this.keys.PrevKey, this._ctx); } } public override bool MemReadStatic { get { return this.ToMemReadWrite(this.op1, this.op2, this.op3); } } public override bool MemWriteStatic { get { return this.ToMemReadWrite(this.op1, this.op2, this.op3); } } } @@ -495,9 +495,9 @@ public OpcodeNBase(Mnemonic mnemonic, string[] args, int maxNArgs, (string prevK } } } - public BitVecExpr Op1Value { get { return OpcodeBase.OpValue(this.op1, this.keys.PrevKey, this._ctx); } } - public BitVecExpr Op2Value { get { return OpcodeBase.OpValue(this.op2, this.keys.PrevKey, this._ctx); } } - public BitVecExpr Op3Value { get { return OpcodeBase.OpValue(this.op3, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op1Value { get { return OpValue(this.op1, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op2Value { get { return OpValue(this.op2, this.keys.PrevKey, this._ctx); } } + public BitVecExpr Op3Value { get { return OpValue(this.op3, this.keys.PrevKey, this._ctx); } } public override bool MemReadStatic { get { return this.ToMemReadWrite(this.op1, this.op2, this.op3); } } public override bool MemWriteStatic { get { return this.ToMemReadWrite(this.op1, this.op2, this.op3); } } } @@ -559,7 +559,7 @@ public override void Execute() if (this.NOperands > 0) { if (this.op1.IsReg) this.RegularUpdate.Set(this.op1.Rn, Tv.UNKNOWN); - else if ((this.op1.IsMem) && (!memAlreadyCleared)) + else if (this.op1.IsMem && (!memAlreadyCleared)) { this.RegularUpdate.Set_Mem_Unknown(); memAlreadyCleared = true; @@ -568,7 +568,7 @@ public override void Execute() if (this.NOperands > 1) { if (this.op2.IsReg) this.RegularUpdate.Set(this.op2.Rn, Tv.UNKNOWN); - else if ((this.op2.IsMem) && (!memAlreadyCleared)) + else if (this.op2.IsMem && (!memAlreadyCleared)) { this.RegularUpdate.Set_Mem_Unknown(); memAlreadyCleared = true; @@ -577,7 +577,7 @@ public override void Execute() if (this.NOperands > 2) { if (this.op3.IsReg) this.RegularUpdate.Set(this.op3.Rn, Tv.UNKNOWN); - else if ((this.op3.IsMem) && (!memAlreadyCleared)) + else if (this.op3.IsMem && (!memAlreadyCleared)) { this.RegularUpdate.Set_Mem_Unknown(); memAlreadyCleared = true; @@ -902,7 +902,7 @@ public Push(string[] args, (string prevKey, string nextKey, string nextKeyBranch { this.SyntaxError = string.Format("\"{0}\": Operand1={1} ({2}, bits={3})", this.ToString(), this.op1, this.op1.Type, this.op1.NBits); } - else if ((this.op1.NBits == 64) && (this.op1.IsImm)) + else if ((this.op1.NBits == 64) && this.op1.IsImm) { this.SyntaxError = string.Format("\"{0}\": Operand1={1} ({2}, bits={3})", this.ToString(), this.op1, this.op1.Type, this.op1.NBits); } @@ -2367,7 +2367,7 @@ public static (BitVecExpr shiftCount, BoolExpr tooLarge) GetShiftCount(BitVecExp } public void UpdateFlagsShift(BitVecExpr value, BoolExpr cfIn, BitVecExpr shiftCount, BoolExpr shiftTooLarge, bool left) { - ShiftRotateBase.UpdateFlagsShift(value, cfIn, shiftCount, shiftTooLarge, left, this.keys.PrevKey, this.RegularUpdate, this.Tools.Rand, this._ctx); + UpdateFlagsShift(value, cfIn, shiftCount, shiftTooLarge, left, this.keys.PrevKey, this.RegularUpdate, this.Tools.Rand, this._ctx); } public static void UpdateFlagsShift(BitVecExpr value, BoolExpr cfIn, BitVecExpr shiftCount, BoolExpr shiftTooLarge, bool left, string prevKey, StateUpdate stateUpdate, Random rand, Context ctx) { @@ -2390,19 +2390,19 @@ public static void UpdateFlagsShift(BitVecExpr value, BoolExpr cfIn, BitVecExpr } BoolExpr of = - ctx.MkITE(shiftTooLarge, OpcodeBase.Undef(Flags.OF, rand, ctx), - ctx.MkITE(isZero, OpcodeBase.Get(Flags.OF, prevKey, ctx), - ctx.MkITE(isOne, of_tmp, OpcodeBase.Undef(Flags.OF, rand, ctx)))) as BoolExpr; + ctx.MkITE(shiftTooLarge, Undef(Flags.OF, rand, ctx), + ctx.MkITE(isZero, Get(Flags.OF, prevKey, ctx), + ctx.MkITE(isOne, of_tmp, Undef(Flags.OF, rand, ctx)))) as BoolExpr; #endregion #region Set the Flags stateUpdate.Set(Flags.OF, of); // if the shift is too larte than CF is undefined; if the shift is zero, than CF is unchanged; otherwise it is the provided value; - stateUpdate.Set(Flags.CF, ctx.MkITE(shiftTooLarge, OpcodeBase.Undef(Flags.CF, rand, ctx), ctx.MkITE(isZero, OpcodeBase.Get(Flags.CF, prevKey, ctx), cfIn)) as BoolExpr); - stateUpdate.Set(Flags.PF, ctx.MkITE(isZero, OpcodeBase.Get(Flags.PF, prevKey, ctx), ToolsFlags.Create_PF(value, ctx)) as BoolExpr); - stateUpdate.Set(Flags.ZF, ctx.MkITE(isZero, OpcodeBase.Get(Flags.ZF, prevKey, ctx), ToolsFlags.Create_ZF(value, ctx)) as BoolExpr); - stateUpdate.Set(Flags.SF, ctx.MkITE(isZero, OpcodeBase.Get(Flags.SF, prevKey, ctx), ToolsFlags.Create_SF(value, value.SortSize, ctx)) as BoolExpr); - stateUpdate.Set(Flags.AF, ctx.MkITE(isZero, OpcodeBase.Get(Flags.AF, prevKey, ctx), OpcodeBase.Undef(Flags.AF, rand, ctx)) as BoolExpr); + stateUpdate.Set(Flags.CF, ctx.MkITE(shiftTooLarge, Undef(Flags.CF, rand, ctx), ctx.MkITE(isZero, Get(Flags.CF, prevKey, ctx), cfIn)) as BoolExpr); + stateUpdate.Set(Flags.PF, ctx.MkITE(isZero, Get(Flags.PF, prevKey, ctx), ToolsFlags.Create_PF(value, ctx)) as BoolExpr); + stateUpdate.Set(Flags.ZF, ctx.MkITE(isZero, Get(Flags.ZF, prevKey, ctx), ToolsFlags.Create_ZF(value, ctx)) as BoolExpr); + stateUpdate.Set(Flags.SF, ctx.MkITE(isZero, Get(Flags.SF, prevKey, ctx), ToolsFlags.Create_SF(value, value.SortSize, ctx)) as BoolExpr); + stateUpdate.Set(Flags.AF, ctx.MkITE(isZero, Get(Flags.AF, prevKey, ctx), Undef(Flags.AF, rand, ctx)) as BoolExpr); #endregion } public void UpdateFlagsRotate(BitVecExpr value, BoolExpr cfIn, BitVecExpr shiftCount, bool left) @@ -2453,7 +2453,7 @@ public sealed class Sar : ShiftRotateBase public Sar(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.SAR, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.SAR, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsShift(result, cf, shiftCount.shiftCount, shiftCount.tooLarge, false); this.RegularUpdate.Set(this.op1, result); @@ -2466,7 +2466,7 @@ public sealed class Sal : ShiftRotateBase public Sal(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.SAL, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.SAL, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsShift(result, cf, shiftCount.shiftCount, shiftCount.tooLarge, true); this.RegularUpdate.Set(this.op1, result); @@ -2479,7 +2479,7 @@ public sealed class Shr : ShiftRotateBase public Shr(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.SHR, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.SHR, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsShift(result, cf, shiftCount.shiftCount, shiftCount.tooLarge, false); this.RegularUpdate.Set(this.op1, result); @@ -2492,7 +2492,7 @@ public sealed class Shl : ShiftRotateBase public Shl(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.SHL, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.SHL, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsShift(result, cf, shiftCount.shiftCount, shiftCount.tooLarge, true); this.RegularUpdate.Set(this.op1, result); @@ -2508,7 +2508,7 @@ public sealed class Ror : ShiftRotateBase public Ror(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.ROR, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.ROR, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsRotate(result, cf, shiftCount.shiftCount, false); this.RegularUpdate.Set(this.op1, result); @@ -2521,7 +2521,7 @@ public sealed class Rcr : ShiftRotateBase public Rcr(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.RCR, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.RCR, this.Op1Value, shiftCount.shiftCount, this.Get(Flags.CF), this.keys.PrevKey, this._ctx); this.UpdateFlagsRotate(result, cf, shiftCount.shiftCount, false); this.RegularUpdate.Set(this.op1, result); @@ -2535,7 +2535,7 @@ public sealed class Rcl : ShiftRotateBase public Rcl(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.RCL, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.RCL, this.Op1Value, shiftCount.shiftCount, this.Get(Flags.CF), this.keys.PrevKey, this._ctx); this.UpdateFlagsRotate(result, cf, shiftCount.shiftCount, true); this.RegularUpdate.Set(this.op1, result); @@ -2549,7 +2549,7 @@ public sealed class Rol : ShiftRotateBase public Rol(string[] args, (string prevKey, string nextKey, string nextKeyBranch) keys, Tools t) : base(Mnemonic.ROL, args, keys, t) { } public override void Execute() { - var shiftCount = ShiftRotateBase.GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); + var shiftCount = GetShiftCount(this.Op2Value, this.op1.NBits, this._ctx); var (result, cf) = BitOperations.ShiftOperations(Mnemonic.ROL, this.Op1Value, shiftCount.shiftCount, this._ctx, this.Tools.Rand); this.UpdateFlagsRotate(result, cf, shiftCount.shiftCount, true); this.RegularUpdate.Set(this.op1, result); @@ -3225,9 +3225,9 @@ public StringOperationAbstract(Mnemonic mnemonic, Mnemonic prefix, string[] args } } - protected Rn SourceIndexReg { get { return (this.Tools.Parameters.mode_64bit) ? Rn.RSI : ((this.Tools.Parameters.mode_32bit) ? Rn.ESI : Rn.SI); } } - protected Rn DestinationIndexReg { get { return (this.Tools.Parameters.mode_64bit) ? Rn.RDI : ((this.Tools.Parameters.mode_32bit) ? Rn.EDI : Rn.DI); } } - protected Rn CounterReg { get { return (this.Tools.Parameters.mode_64bit) ? Rn.RCX : ((this.Tools.Parameters.mode_32bit) ? Rn.ECX : Rn.CX); } } + protected Rn SourceIndexReg { get { return this.Tools.Parameters.mode_64bit ? Rn.RSI : (this.Tools.Parameters.mode_32bit ? Rn.ESI : Rn.SI); } } + protected Rn DestinationIndexReg { get { return this.Tools.Parameters.mode_64bit ? Rn.RDI : (this.Tools.Parameters.mode_32bit ? Rn.EDI : Rn.DI); } } + protected Rn CounterReg { get { return this.Tools.Parameters.mode_64bit ? Rn.RCX : (this.Tools.Parameters.mode_32bit ? Rn.ECX : Rn.CX); } } protected Rn AccumulatorReg { get @@ -3248,7 +3248,7 @@ protected BitVecNum IncrementBV { get { - int nBits = (this.Tools.Parameters.mode_64bit) ? 64 : ((this.Tools.Parameters.mode_32bit) ? 32 : 16); + int nBits = this.Tools.Parameters.mode_64bit ? 64 : (this.Tools.Parameters.mode_32bit ? 32 : 16); return this._ctx.MkBV(this._nBytes, (uint)nBits); } } diff --git a/VS/CSHARP/asm-sim-lib/Runner.cs b/VS/CSHARP/asm-sim-lib/Runner.cs index 34ec937f..108baaa4 100644 --- a/VS/CSHARP/asm-sim-lib/Runner.cs +++ b/VS/CSHARP/asm-sim-lib/Runner.cs @@ -66,7 +66,7 @@ public static State SimpleStep_Forward(string line, State state) string nextKey = Tools.CreateKey(tools.Rand); string nextKeyBranch = "DUMMY_NOT_USED"; var content = AsmSourceTools.ParseLine(line); - using (var opcodeBase = Runner.InstantiateOpcode(content.Mnemonic, content.Args, (state.HeadKey, nextKey, nextKeyBranch), tools)) + using (var opcodeBase = InstantiateOpcode(content.Mnemonic, content.Args, (state.HeadKey, nextKey, nextKeyBranch), tools)) { if (opcodeBase == null) return null; if (opcodeBase.IsHalted) @@ -101,7 +101,7 @@ public static State SimpleStep_Backward(string line, State state) { string prevKey = Tools.CreateKey(state.Tools.Rand); var content = AsmSourceTools.ParseLine(line); - using (var opcodeBase = Runner.InstantiateOpcode(content.Mnemonic, content.Args, (prevKey, state.TailKey, state.TailKey), state.Tools)) + using (var opcodeBase = InstantiateOpcode(content.Mnemonic, content.Args, (prevKey, state.TailKey, state.TailKey), state.Tools)) { if (opcodeBase == null) return null; if (opcodeBase.IsHalted) return null; @@ -133,7 +133,7 @@ public static (State Regular, State Branch) Step_Forward(string line, State stat string nextKey = Tools.CreateKey(state.Tools.Rand); string nextKeyBranch = nextKey + "!BRANCH"; var content = AsmSourceTools.ParseLine(line); - using (var opcodeBase = Runner.InstantiateOpcode(content.Mnemonic, content.Args, (state.HeadKey, nextKey, nextKeyBranch), state.Tools)) + using (var opcodeBase = InstantiateOpcode(content.Mnemonic, content.Args, (state.HeadKey, nextKey, nextKeyBranch), state.Tools)) { if (opcodeBase == null) return (Regular: null, Branch: null); if (opcodeBase.IsHalted) return (Regular: null, Branch: null); @@ -172,7 +172,7 @@ public static (StateUpdate Regular, StateUpdate Branch) Execute( try { var content = sFlow.Get_Line(lineNumber); - using (var opcodeBase = Runner.InstantiateOpcode(content.Mnemonic, content.Args, keys, tools)) + using (var opcodeBase = InstantiateOpcode(content.Mnemonic, content.Args, keys, tools)) { if ((opcodeBase == null) || opcodeBase.IsHalted) { diff --git a/VS/CSHARP/asm-sim-lib/State.cs b/VS/CSHARP/asm-sim-lib/State.cs index 0a66608e..5fc97fd6 100644 --- a/VS/CSHARP/asm-sim-lib/State.cs +++ b/VS/CSHARP/asm-sim-lib/State.cs @@ -67,8 +67,8 @@ private State(Tools tools) { this._tools = new Tools(tools); this._ctx = new Context(this._tools.Settings); // housekeeping in Dispose(); - this.Solver = State.MakeSolver(this._ctx); - this.Solver_U = State.MakeSolver(this._ctx); + this.Solver = MakeSolver(this._ctx); + this.Solver_U = MakeSolver(this._ctx); this._branchInfoStore = new BranchInfoStore(this._ctx); this._cached_Reg_Values = new Dictionary(); this._cached_Flag_Values = new Dictionary(); @@ -344,7 +344,7 @@ public void Add(BranchInfo branchInfo) #region Getters public bool Is_Undefined(Flags flagName) { - return (this.GetTv(flagName) == Tv.UNDEFINED); + return this.GetTv(flagName) == Tv.UNDEFINED; } public bool Is_Undefined(Rn regName) { @@ -382,7 +382,7 @@ public bool Is_Redundant(Flags flagName, string key1, string key2) this.Solver.Pop(); this.Solver_U.Pop(); } - return (result == Tv.ONE); + return result == Tv.ONE; } } } @@ -412,7 +412,7 @@ public bool Is_Redundant(Rn regName, string key1, string key2) this.Solver.Pop(); this.Solver_U.Pop(); } - return (result == Tv.ONE); + return result == Tv.ONE; } } } @@ -508,7 +508,7 @@ public Tv[] GetTvArray(Rn regName) { lock (this._ctxLock) { - if (this.Frozen && (this._cached_Reg_Values.TryGetValue(regName, out var value))) + if (this.Frozen && this._cached_Reg_Values.TryGetValue(regName, out var value)) { return value; } @@ -741,7 +741,7 @@ public string ToStringRegs(string identStr) { Tv[] regContent = this.GetTvArray(reg); var (hasOneValue, value) = ToolsZ3.HasOneValue(regContent); - bool showReg = (!(hasOneValue && value == Tv.UNKNOWN)); + bool showReg = !(hasOneValue && value == Tv.UNKNOWN); if (showReg) sb.Append("\n" + identStr + string.Format(reg + " = {0} = {1}", ToolsZ3.ToStringBin(regContent), ToolsZ3.ToStringHex(regContent))); } return sb.ToString(); @@ -754,7 +754,7 @@ public string ToStringSIMD(string identStr) Rn reg = Rn.XMM1; Tv[] regContent = this.GetTvArray(reg); var (hasOneValue, value) = ToolsZ3.HasOneValue(regContent); - bool showReg = (!(hasOneValue && value == Tv.UNKNOWN)); + bool showReg = !(hasOneValue && value == Tv.UNKNOWN); if (showReg) sb.Append("\n" + identStr + string.Format(reg + " = {0} = {1}", ToolsZ3.ToStringBin(regContent), ToolsZ3.ToStringHex(regContent))); } return sb.ToString(); diff --git a/VS/CSHARP/asm-sim-lib/StateUpdate.cs b/VS/CSHARP/asm-sim-lib/StateUpdate.cs index 69b092c5..d013c2fe 100644 --- a/VS/CSHARP/asm-sim-lib/StateUpdate.cs +++ b/VS/CSHARP/asm-sim-lib/StateUpdate.cs @@ -266,25 +266,25 @@ private BoolExpr Get_Raw_Private(Rn reg, bool undef) { switch (reg) { - case Rn.RAX: return (undef) ? this._rax_U : this._rax; - case Rn.RBX: return (undef) ? this._rbx_U : this._rbx; - case Rn.RCX: return (undef) ? this._rcx_U : this._rcx; - case Rn.RDX: return (undef) ? this._rdx_U : this._rdx; - - case Rn.RSI: return (undef) ? this._rsi_U : this._rsi; - case Rn.RDI: return (undef) ? this._rdi_U : this._rdi; - case Rn.RBP: return (undef) ? this._rbp_U : this._rbp; - case Rn.RSP: return (undef) ? this._rsp_U : this._rsp; - - case Rn.R8: return (undef) ? this._r8_U : this._r8; - case Rn.R9: return (undef) ? this._r9_U : this._r9; - case Rn.R10: return (undef) ? this._r10_U : this._r10; - case Rn.R11: return (undef) ? this._r11_U : this._r11; - - case Rn.R12: return (undef) ? this._r12_U : this._r12; - case Rn.R13: return (undef) ? this._r13_U : this._r13; - case Rn.R14: return (undef) ? this._r14_U : this._r14; - case Rn.R15: return (undef) ? this._r15_U : this._r15; + case Rn.RAX: return undef ? this._rax_U : this._rax; + case Rn.RBX: return undef ? this._rbx_U : this._rbx; + case Rn.RCX: return undef ? this._rcx_U : this._rcx; + case Rn.RDX: return undef ? this._rdx_U : this._rdx; + + case Rn.RSI: return undef ? this._rsi_U : this._rsi; + case Rn.RDI: return undef ? this._rdi_U : this._rdi; + case Rn.RBP: return undef ? this._rbp_U : this._rbp; + case Rn.RSP: return undef ? this._rsp_U : this._rsp; + + case Rn.R8: return undef ? this._r8_U : this._r8; + case Rn.R9: return undef ? this._r9_U : this._r9; + case Rn.R10: return undef ? this._r10_U : this._r10; + case Rn.R11: return undef ? this._r11_U : this._r11; + + case Rn.R12: return undef ? this._r12_U : this._r12; + case Rn.R13: return undef ? this._r13_U : this._r13; + case Rn.R14: return undef ? this._r14_U : this._r14; + case Rn.R15: return undef ? this._r15_U : this._r15; default: throw new Exception(); } @@ -314,13 +314,13 @@ private BoolExpr Get_Raw_Private(Flags flag, bool undef) { switch (flag) { - case Flags.CF: return (undef) ? this._cf_U : this._cf; - case Flags.PF: return (undef) ? this._pf_U : this._pf; - case Flags.AF: return (undef) ? this._af_U : this._af; - case Flags.ZF: return (undef) ? this._zf_U : this._zf; - case Flags.SF: return (undef) ? this._sf_U : this._sf; - case Flags.OF: return (undef) ? this._of_U : this._of; - case Flags.DF: return (undef) ? this._df_U : this._df; + case Flags.CF: return undef ? this._cf_U : this._cf; + case Flags.PF: return undef ? this._pf_U : this._pf; + case Flags.AF: return undef ? this._af_U : this._af; + case Flags.ZF: return undef ? this._zf_U : this._zf; + case Flags.SF: return undef ? this._sf_U : this._sf; + case Flags.OF: return undef ? this._of_U : this._of; + case Flags.DF: return undef ? this._df_U : this._df; default: throw new Exception(); } } @@ -383,7 +383,7 @@ public string NextKey #region Set Flag public void Set(Flags flag, bool value) { - this.Set(flag, (value) ? Tv.ONE : Tv.ZERO); + this.Set(flag, value ? Tv.ONE : Tv.ZERO); } public void Set(Flags flag, Tv value) { @@ -598,7 +598,7 @@ public void Set(Rn reg, BitVecExpr value, BitVecExpr undef) } else if (RegisterTools.Is_SIMD_Register(reg)) { - uint max = (512 * 32); + uint max = 512 * 32; BitVecExpr prevKey = ctx.MkBVConst(Tools.Reg_Name(reg, this._prevKey_Regular), max); var (High, Low) = Tools.SIMD_Extract_Range(reg); diff --git a/VS/CSHARP/asm-sim-lib/StaticFlow.cs b/VS/CSHARP/asm-sim-lib/StaticFlow.cs index 440839c0..8a419778 100644 --- a/VS/CSHARP/asm-sim-lib/StaticFlow.cs +++ b/VS/CSHARP/asm-sim-lib/StaticFlow.cs @@ -76,7 +76,7 @@ public StateConfig Create_StateConfig( { if (opcodeBase != null) { - flags |= (opcodeBase.FlagsReadStatic | opcodeBase.FlagsWriteStatic); + flags |= opcodeBase.FlagsReadStatic | opcodeBase.FlagsWriteStatic; foreach (Rn r in opcodeBase.RegsReadStatic) regs.Add(RegisterTools.Get64BitsRegister(r)); foreach (Rn r in opcodeBase.RegsWriteStatic) regs.Add(RegisterTools.Get64BitsRegister(r)); mem |= opcodeBase.MemWriteStatic || opcodeBase.MemReadStatic; @@ -100,7 +100,7 @@ public string Get_Key(int lineNumber) } else { - return "!" + (lineNumber).ToString(); + return "!" + lineNumber.ToString(); } } public (string Key1, string Key2) Get_Key((int lineNumber1, int lineNumber2) lineNumber) @@ -153,7 +153,7 @@ public bool HasLine(int lineNumber) public string Get_Line_Str(int lineNumber) { - return (this.HasLine(lineNumber)) ? StaticFlow.ToString(this.Current[lineNumber]) : ""; + return this.HasLine(lineNumber) ? ToString(this.Current[lineNumber]) : ""; } public bool Has_Prev_LineNumber(int lineNumber) @@ -278,13 +278,13 @@ void FutureLineNumbers_Local(int lineNumber2) /// A BranchPoint is an code line that has two next states (that need not be different) public bool Is_Branch_Point(int lineNumber) { - return (this._graph.OutDegree(lineNumber) > 1); + return this._graph.OutDegree(lineNumber) > 1; } /// A MergePoint is a code line which has at least two control flows that merge into this line public bool Is_Merge_Point(int lineNumber) { - return (this._graph.InDegree(lineNumber) > 1); + return this._graph.InDegree(lineNumber) > 1; } #endregion @@ -446,7 +446,7 @@ public static string ToString((string label, Mnemonic mnemonic, string[] args) t } else { - return string.Format("{0}{1} {2}", ((t.label.Length > 0) ? (t.label + ": ") : ""), t.mnemonic, arguments); + return string.Format("{0}{1} {2}", (t.label.Length > 0) ? (t.label + ": ") : "", t.mnemonic, arguments); } } @@ -461,7 +461,7 @@ public override string ToString() sb.Append(" [Prev:"); foreach (var (LineNumber, IsBranch) in this.Get_Prev_LineNumber(i)) { - sb.Append(LineNumber + ((IsBranch) ? "B" : "R") + ","); // B=Branching; R=Regular Continuation + sb.Append(LineNumber + (IsBranch ? "B" : "R") + ","); // B=Branching; R=Regular Continuation } sb.Append("][Next:"); var (Regular, Branch) = this.Get_Next_LineNumber(i); @@ -477,11 +477,11 @@ public override string ToString() #region Private Methods private IList<(string Label, Mnemonic Mnemonic, string[] Args)> Current { - get { return (this._use_Parsed_Code_A) ? this._parsed_Code_A : this._parsed_Code_B; } + get { return this._use_Parsed_Code_A ? this._parsed_Code_A : this._parsed_Code_B; } } private IList<(string Label, Mnemonic Mnemonic, string[] Args)> Previous { - get { return (this._use_Parsed_Code_A) ? this._parsed_Code_B : this._parsed_Code_A; } + get { return this._use_Parsed_Code_A ? this._parsed_Code_B : this._parsed_Code_A; } } private void Add_Edge(int jumpFrom, int jumpTo, bool isBranch) @@ -581,7 +581,7 @@ private IDictionary GetLabels(string text) for (int lineNumber = 0; lineNumber < lines.Length; ++lineNumber) { string line = lines[lineNumber]; - var (Valid, BeginPos, EndPos) = AsmTools.AsmSourceTools.GetLabelDefPos(line); + var (Valid, BeginPos, EndPos) = AsmSourceTools.GetLabelDefPos(line); if (Valid) { int labelBeginPos = BeginPos; diff --git a/VS/CSHARP/asm-sim-lib/Tools.cs b/VS/CSHARP/asm-sim-lib/Tools.cs index 8a6f39a0..201b4ef7 100644 --- a/VS/CSHARP/asm-sim-lib/Tools.cs +++ b/VS/CSHARP/asm-sim-lib/Tools.cs @@ -205,7 +205,7 @@ public static BitVecExpr Create_Key(Rn reg, String key, Context ctx) if (RegisterTools.Is_SIMD_Register(reg)) { var (High, Low) = SIMD_Extract_Range(reg); - return ctx.MkExtract(High, Low, ctx.MkBVConst(Tools.Reg_Name(reg, key), 32 * 512)); + return ctx.MkExtract(High, Low, ctx.MkBVConst(Reg_Name(reg, key), 32 * 512)); } else if (RegisterTools.IsGeneralPurposeRegister(reg)) { @@ -216,7 +216,7 @@ public static BitVecExpr Create_Key(Rn reg, String key, Context ctx) else { Rn reg64 = RegisterTools.Get64BitsRegister(reg); - return (RegisterTools.Is8BitHigh(reg)) + return RegisterTools.Is8BitHigh(reg) ? ctx.MkExtract(15, 8, ctx.MkBVConst(Reg_Name(reg64, key), 64)) : ctx.MkExtract(nBits - 1, 0, ctx.MkBVConst(Reg_Name(reg64, key), 64)); } @@ -258,7 +258,7 @@ public static BitVecExpr Calc_Effective_Address(Operand op, string key, Context if (op.IsReg) { - return Tools.Create_Key(op.Rn, key, ctx); + return Create_Key(op.Rn, key, ctx); } else if (op.IsMem) { @@ -284,9 +284,9 @@ public static BitVecExpr Calc_Effective_Address(Operand op, string key, Context BitVecExpr baseRegister; switch (RegisterTools.NBits(BaseReg)) { - case 64: baseRegister = Tools.Create_Key(BaseReg, key, ctx); break; - case 32: baseRegister = ctx.MkZeroExt(32, Tools.Create_Key(BaseReg, key, ctx)); break; - case 16: baseRegister = ctx.MkZeroExt(48, Tools.Create_Key(BaseReg, key, ctx)); break; + case 64: baseRegister = Create_Key(BaseReg, key, ctx); break; + case 32: baseRegister = ctx.MkZeroExt(32, Create_Key(BaseReg, key, ctx)); break; + case 16: baseRegister = ctx.MkZeroExt(48, Create_Key(BaseReg, key, ctx)); break; default: throw new Exception(); } //Console.WriteLine("baseRegister.NBits = " + baseRegister.SortSize + "; address.NBits = " + address.SortSize); @@ -299,7 +299,7 @@ public static BitVecExpr Calc_Effective_Address(Operand op, string key, Context { if (Scale > 0) { - BitVecExpr indexRegister = Tools.Create_Key(IndexReg, key, ctx); + BitVecExpr indexRegister = Create_Key(IndexReg, key, ctx); switch (Scale) { case 0: @@ -345,7 +345,7 @@ public static BitVecExpr Create_Value_From_Mem(BitVecExpr address, int nBytes, s { Debug.Assert(nBytes > 0, "Number of bytes has to larger than zero. nBytes=" + nBytes); - ArrayExpr mem = Tools.Create_Mem_Key(key, ctx); + ArrayExpr mem = Create_Mem_Key(key, ctx); BitVecExpr result = ctx.MkSelect(mem, address) as BitVecExpr; for (uint i = 1; i < nBytes; ++i) @@ -370,7 +370,7 @@ public static ArrayExpr Set_Value_To_Mem(BitVecExpr value, BitVecExpr address, s for (uint i = 0; i < nBytes; ++i) { BitVecExpr address2 = ctx.MkBVAdd(address, ctx.MkBV(i, 64)); - mem = ctx.MkStore(mem, address2, ctx.MkExtract((8 * (i + 1)) - 1, (8 * i), value)); + mem = ctx.MkStore(mem, address2, ctx.MkExtract((8 * (i + 1)) - 1, 8 * i, value)); } return mem; } diff --git a/VS/CSHARP/asm-sim-lib/ToolsZ3.cs b/VS/CSHARP/asm-sim-lib/ToolsZ3.cs index d8059bd4..154f3f3a 100644 --- a/VS/CSHARP/asm-sim-lib/ToolsZ3.cs +++ b/VS/CSHARP/asm-sim-lib/ToolsZ3.cs @@ -154,7 +154,7 @@ private static (bool valid, ulong value) IsSimpleAssignment_UNUSED(string name, { //Console.WriteLine("isSimpleAssignment: " + e + "; found name " + name+ "; type second argument ="+ e.Args[1].GetType()); - if (e.Args[1].GetType().Equals(typeof(Microsoft.Z3.BitVecNum))) + if (e.Args[1].GetType().Equals(typeof(BitVecNum))) { //Console.WriteLine("isSimpleAssignment: e=" + e + "; second argument is numeral "+e.Args[1]); BitVecNum value = e.Args[1] as BitVecNum; @@ -335,11 +335,11 @@ public static bool Equals(BitVecExpr valueExpr, BitVecExpr undef, Tv[] valueTv, { for (uint bit = 0; bit < nBits; ++bit) { - using (BoolExpr b = ToolsZ3.GetBit(valueExpr, bit, bv1_1bit, ctx)) - using (BoolExpr b_undef = ToolsZ3.GetBit(undef, bit, bv1_1bit, ctx)) + using (BoolExpr b = GetBit(valueExpr, bit, bv1_1bit, ctx)) + using (BoolExpr b_undef = GetBit(undef, bit, bv1_1bit, ctx)) { // this can be done faster - Tv tv = ToolsZ3.GetTv(b, b_undef, solver, solver_U, ctx); + Tv tv = GetTv(b, b_undef, solver, solver_U, ctx); if (tv != valueTv[bit]) return false; } } @@ -350,8 +350,8 @@ public static bool Equals(BitVecExpr valueExpr, BitVecExpr undef, Tv[] valueTv, public static bool Equals(BoolExpr valueExpr, BoolExpr undef, Tv valueTv, Solver solver, Solver solver_U, Context ctx) { // this can be done faster - Tv tv = ToolsZ3.GetTv(valueExpr, undef, solver, solver_U, ctx); - return (tv == Tv.ONE); + Tv tv = GetTv(valueExpr, undef, solver, solver_U, ctx); + return tv == Tv.ONE; } private static Flags CollectFlags_UNUSED(Expr e) @@ -371,7 +371,7 @@ private static void CollectFlags_UNUSED(Expr e, ref Flags flags) { foreach (Expr e2 in e.Args) { - ToolsZ3.CollectFlags_UNUSED(e2, ref flags); + CollectFlags_UNUSED(e2, ref flags); } } } @@ -387,7 +387,7 @@ private static void CollectConstants_UNUSED(Expr e, ref ISet set) { foreach (Expr e2 in e.Args) { - ToolsZ3.CollectConstants_UNUSED(e2, ref set); + CollectConstants_UNUSED(e2, ref set); } } } @@ -416,9 +416,9 @@ public static string ToStringBin(Tv[] a) else { int nBits = a.Length; - for (int i = (nBits - 1); i >= 0; --i) + for (int i = nBits - 1; i >= 0; --i) { - sb.Append(ToolsZ3.ToStringBin(a[i])); + sb.Append(ToStringBin(a[i])); if ((i > 0) && (i != nBits - 1) && (i % 8 == 0)) sb.Append('_'); } } @@ -431,7 +431,7 @@ public static string ToStringHex(Tv[] a) int offset = 0; while (offset < a.Length) { - str = ToolsZ3.BitToCharHex(GetTv(offset), GetTv(offset + 1), GetTv(offset + 2), GetTv(offset + 3)) + str; + str = BitToCharHex(GetTv(offset), GetTv(offset + 1), GetTv(offset + 2), GetTv(offset + 3)) + str; offset += 4; if ((offset > 0) && (offset < a.Length) && ((offset % 16) == 0)) str = '_' + str; } @@ -460,7 +460,7 @@ public static string ToStringDec(Tv[] a) switch (a[i]) { case Tv.ONE: - result |= (1UL << i); + result |= 1UL << i; break; case Tv.ZERO: break; @@ -478,7 +478,7 @@ public static string ToStringOct(Tv[] a) int offset = 0; while (offset < a.Length) { - str = ToolsZ3.BitToCharOct(GetTv(offset), GetTv(offset + 1), GetTv(offset + 2)) + str; + str = BitToCharOct(GetTv(offset), GetTv(offset + 1), GetTv(offset + 2)) + str; offset += 3; if ((offset > 0) && (offset < a.Length) && ((offset % 9) == 0)) str = '_' + str; } @@ -573,9 +573,9 @@ public static char BitToCharOct(Tv b0, Tv b1, Tv b2) { for (uint bit = 0; bit < nBits; ++bit) { - using (BoolExpr b = ToolsZ3.GetBit(value, bit, ONE, ctx)) + using (BoolExpr b = GetBit(value, bit, ONE, ctx)) { - switch (ToolsZ3.GetTv(b, solver, ctx)) + switch (GetTv(b, solver, ctx)) { case Tv.ONE: results[bit] = Tv.ONE; @@ -589,7 +589,7 @@ public static char BitToCharOct(Tv b0, Tv b1, Tv b2) } } } - return ToolsZ3.ToUlong(results); + return ToUlong(results); } public static ulong? ToUlong(Tv[] array) { @@ -599,7 +599,7 @@ public static char BitToCharOct(Tv b0, Tv b1, Tv b2) switch (array[i]) { case Tv.ONE: - result |= (1UL << i); + result |= 1UL << i; break; case Tv.ZERO: break; @@ -668,10 +668,10 @@ public static Tv[] GetTvArray(BitVecExpr value, BitVecExpr undef, int nBits, Sol { for (uint bit = 0; bit < nBits; ++bit) { - using (BoolExpr b = ToolsZ3.GetBit(value, bit, bv1_1bit, ctx)) - using (BoolExpr b_undef = ToolsZ3.GetBit(undef, bit, bv1_1bit, ctx)) + using (BoolExpr b = GetBit(value, bit, bv1_1bit, ctx)) + using (BoolExpr b_undef = GetBit(undef, bit, bv1_1bit, ctx)) { - results[bit] = ToolsZ3.GetTv(b, b_undef, solver, solver_U, ctx); + results[bit] = GetTv(b, b_undef, solver, solver_U, ctx); } } } @@ -689,9 +689,9 @@ public static Tv[] GetTvArray(BitVecExpr value, int nBits, Solver solver, Contex { for (uint bit = 0; bit < nBits; ++bit) { - using (BoolExpr b = ToolsZ3.GetBit(value, bit, bv1_1bit, ctx)) + using (BoolExpr b = GetBit(value, bit, bv1_1bit, ctx)) { - results[bit] = ToolsZ3.GetTv(b, solver, ctx); + results[bit] = GetTv(b, solver, ctx); } } } @@ -702,7 +702,7 @@ public static Tv GetTv(BoolExpr value, BoolExpr undef, Solver solver, Solver sol { try { - return (freshSolver) + return freshSolver ? GetTv_Method1(value, undef, solver, solver_U, ctx) : GetTv_Method2(value, undef, solver, solver_U, ctx); } @@ -722,7 +722,7 @@ private static Tv GetTv_Method1(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: A: value=" + value + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvTrue = (status == Status.SATISFIABLE); + tvTrue = status == Status.SATISFIABLE; } //if (!tvTrue) return Tv5.ZERO; @@ -737,7 +737,7 @@ private static Tv GetTv_Method1(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: B: value=" + ctx.MkNot(value) + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvFalse = (status == Status.SATISFIABLE); + tvFalse = status == Status.SATISFIABLE; } } // if it consistent to assert that the provided bit is true, @@ -760,7 +760,7 @@ private static Tv GetTv_Method1(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: C: undef=" + ctx.MkNot(undef) + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvFalseU = (status == Status.SATISFIABLE); + tvFalseU = status == Status.SATISFIABLE; } } // if (!tvFalseU) return Tv5.UNKNOWN; @@ -773,7 +773,7 @@ private static Tv GetTv_Method1(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: D: undef=" + undef + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvTrueU = (status == Status.SATISFIABLE); + tvTrueU = status == Status.SATISFIABLE; } return (tvTrueU && tvFalseU) ? Tv.UNDEFINED : Tv.UNKNOWN; } @@ -796,7 +796,7 @@ private static Tv GetTv_Method2(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: A: value=" + value + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvTrue = (status == Status.SATISFIABLE); + tvTrue = status == Status.SATISFIABLE; } } @@ -814,7 +814,7 @@ private static Tv GetTv_Method2(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: B: value=" + ctx.MkNot(value) + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvFalse = (status == Status.SATISFIABLE); + tvFalse = status == Status.SATISFIABLE; } } // if it consistent to assert that the provided bit is true, @@ -839,7 +839,7 @@ private static Tv GetTv_Method2(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: C: undef=" + ctx.MkNot(undef) + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvFalseU = (status == Status.SATISFIABLE); + tvFalseU = status == Status.SATISFIABLE; } } // if (!tvFalseU) return Tv5.UNKNOWN; @@ -856,7 +856,7 @@ private static Tv GetTv_Method2(BoolExpr value, BoolExpr undef, Solver solver, S //Console.WriteLine("ToolsZ3:getTv5: D: undef=" + undef + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvTrueU = (status == Status.SATISFIABLE); + tvTrueU = status == Status.SATISFIABLE; } } return (tvTrueU && tvFalseU) ? Tv.UNDEFINED : Tv.UNKNOWN; @@ -880,7 +880,7 @@ public static Tv GetTv(BoolExpr value, Solver solver, Context ctx) //Console.WriteLine("ToolsZ3:getTv5: A: value=" + value + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvTrue = (status == Status.SATISFIABLE); + tvTrue = status == Status.SATISFIABLE; solver.Pop(); } @@ -896,7 +896,7 @@ public static Tv GetTv(BoolExpr value, Solver solver, Context ctx) //Console.WriteLine("ToolsZ3:getTv5: B: value=" + ctx.MkNot(value) + " yields UNKNOWN solver status. Reason: " + solver.ReasonUnknown); return Tv.UNDETERMINED; } - tvFalse = (status == Status.SATISFIABLE); + tvFalse = status == Status.SATISFIABLE; solver.Pop(); } // if it consistent to assert that the provided bit is true, @@ -943,7 +943,7 @@ private static (IList BoolConstants, IList BvConstants) GetConst { IList boolResults = new List(); IList bvResults = new List(); - ToolsZ3.GetConstants(expr, ref boolResults, ref bvResults); + GetConstants(expr, ref boolResults, ref bvResults); return (BoolConstants: boolResults, BvConstants: bvResults); } diff --git a/VS/CSHARP/asm-sim-lib/asm-sim-lib.csproj b/VS/CSHARP/asm-sim-lib/asm-sim-lib.csproj index 202de596..6db7e565 100644 --- a/VS/CSHARP/asm-sim-lib/asm-sim-lib.csproj +++ b/VS/CSHARP/asm-sim-lib/asm-sim-lib.csproj @@ -120,12 +120,24 @@ 4.5.0 + + 15.8.36 + + + 16.0.96-beta + 3.6.61119.7 2.2.4 + + 1.2.0-beta2 + + + 1.2.0-beta2 + 4.5.0 diff --git a/VS/CSHARP/asm-sim-main/DotVisualizer.cs b/VS/CSHARP/asm-sim-main/DotVisualizer.cs index e8ce2652..93bf1413 100644 --- a/VS/CSHARP/asm-sim-main/DotVisualizer.cs +++ b/VS/CSHARP/asm-sim-main/DotVisualizer.cs @@ -33,7 +33,7 @@ public static class DotVisualizer { public static void SaveToDot(StaticFlow sFlow, DynamicFlow dFlow, string filename) { - var displayGraph = new QuickGraph.AdjacencyGraph>(); + var displayGraph = new AdjacencyGraph>(); foreach (var vertex in dFlow.Graph.Vertices) { @@ -45,7 +45,7 @@ public static void SaveToDot(StaticFlow sFlow, DynamicFlow dFlow, string filenam string displayInfo = sFlow.Get_Line_Str(lineNumber) + "\n" + edge.Tag.StateUpdate.ToString2(); displayGraph.AddEdge(new TaggedEdge(edge.Source, edge.Target, displayInfo)); } - DotVisualizer.Visualize(displayGraph, filename); + Visualize(displayGraph, filename); } public static void ShowPicture(string filename) @@ -109,7 +109,7 @@ public string Run(GraphvizImageType imageType, string dot, string outputFileName if (true) { process.WaitForExit(); - DotVisualizer.ShowPicture(outputFileName + ".jpg"); + ShowPicture(outputFileName + ".jpg"); } } return output; diff --git a/VS/CSHARP/asm-sim-main/ProgramZ3.cs b/VS/CSHARP/asm-sim-main/ProgramZ3.cs index f6cf9668..1f1c710d 100644 --- a/VS/CSHARP/asm-sim-main/ProgramZ3.cs +++ b/VS/CSHARP/asm-sim-main/ProgramZ3.cs @@ -1556,7 +1556,7 @@ static void TestMemoryLeak() Console.WriteLine(string.Format("When a key is pressed ctxArray goes out of scope and may be garbage collected.")); Console.ReadKey(); - System.GC.Collect(); + GC.Collect(); } static void Test_NullReference_Bsf_1() diff --git a/VS/CSHARP/asm-tools-lib/Arch.cs b/VS/CSHARP/asm-tools-lib/Arch.cs index bdfdd491..1d424c0b 100644 --- a/VS/CSHARP/asm-tools-lib/Arch.cs +++ b/VS/CSHARP/asm-tools-lib/Arch.cs @@ -414,7 +414,7 @@ public static string ToString(IEnumerable archs) { bool empty = true; StringBuilder sb = new StringBuilder(); foreach (Arch arch in archs) { - sb.Append(ArchTools.ToString(arch)); + sb.Append(ToString(arch)); sb.Append(","); empty = false; } diff --git a/VS/CSHARP/asm-tools-lib/AsmSourceTools.cs b/VS/CSHARP/asm-tools-lib/AsmSourceTools.cs index ae0c160b..787b97de 100644 --- a/VS/CSHARP/asm-tools-lib/AsmSourceTools.cs +++ b/VS/CSHARP/asm-tools-lib/AsmSourceTools.cs @@ -44,7 +44,7 @@ public static (string Label, Mnemonic Mnemonic, string[] Args, string Remark) Pa if (line.Length > 0) { - var (Valid, BeginPos, EndPos) = AsmTools.AsmSourceTools.GetLabelDefPos(line); + var (Valid, BeginPos, EndPos) = GetLabelDefPos(line); int codeBeginPos = 0; if (Valid) { @@ -57,7 +57,7 @@ public static (string Label, Mnemonic Mnemonic, string[] Args, string Remark) Pa //Console.WriteLine("found label " + label); } - var remarkPos = AsmTools.AsmSourceTools.GetRemarkPos(line); + var remarkPos = GetRemarkPos(line); int codeEndPos = line.Length; if (remarkPos.Valid) { @@ -73,12 +73,12 @@ public static (string Label, Mnemonic Mnemonic, string[] Args, string Remark) Pa //Console.WriteLine(codeStr + ":" + codeStr.Length); // get the first keyword, check if it is a mnemonic - var keyword1Pos = AsmTools.AsmSourceTools.GetKeywordPos(0, codeStr); // find a keyword starting a position 0 + var keyword1Pos = GetKeywordPos(0, codeStr); // find a keyword starting a position 0 string keyword1 = codeStr.Substring(keyword1Pos.BeginPos, keyword1Pos.EndPos - keyword1Pos.BeginPos); if (keyword1.Length > 0) { int startArgPos = keyword1Pos.EndPos; - mnemonic = AsmTools.AsmSourceTools.ParseMnemonic(keyword1, true); + mnemonic = ParseMnemonic(keyword1, true); switch (mnemonic) { case Mnemonic.NONE: break; @@ -89,15 +89,15 @@ public static (string Label, Mnemonic Mnemonic, string[] Args, string Remark) Pa case Mnemonic.REPNZ: { // find a second keyword starting a postion keywordPos.EndPos - var keyword2Pos = AsmTools.AsmSourceTools.GetKeywordPos(keyword1Pos.EndPos+1, codeStr); // find a keyword starting a position 0 + var keyword2Pos = GetKeywordPos(keyword1Pos.EndPos+1, codeStr); // find a keyword starting a position 0 string keyword2 = codeStr.Substring(keyword2Pos.BeginPos, keyword2Pos.EndPos - keyword2Pos.BeginPos); if (keyword2.Length > 0) { - Mnemonic mnemonic2 = AsmTools.AsmSourceTools.ParseMnemonic(keyword2, true); + Mnemonic mnemonic2 = ParseMnemonic(keyword2, true); if (mnemonic2 != Mnemonic.NONE) { startArgPos = keyword2Pos.EndPos; - mnemonic = AsmTools.AsmSourceTools.ParseMnemonic(mnemonic.ToString() + "_" + mnemonic2.ToString(), true); + mnemonic = ParseMnemonic(mnemonic.ToString() + "_" + mnemonic2.ToString(), true); } } break; @@ -305,7 +305,7 @@ public static bool IsInRemark(int pos, string line) int startPos = (pos >= nChars) ? nChars - 1 : pos; for (int i = startPos; i >= 0; --i) { - if (AsmSourceTools.IsRemarkChar(line[i])) + if (IsRemarkChar(line[i])) { return true; } @@ -324,7 +324,7 @@ public static bool IsRemarkOnly(string line) for (int i = 0; i < nChars; ++i) { char c = line[i]; - if (AsmSourceTools.IsRemarkChar(c)) + if (IsRemarkChar(c)) { return true; } @@ -348,7 +348,7 @@ public static int GetRemarkCharPosition(string line) { for (int i = 0; i < line.Length; ++i) { - if (AsmSourceTools.IsRemarkChar(line[i])) + if (IsRemarkChar(line[i])) { return i; } @@ -486,7 +486,7 @@ public static (bool Valid, Rn BaseReg, Rn IndexReg, int Scale, long Displacement else { foundDisplacement = true; - displacement = (negativeDisplacement) ? -(long)Value : (long)Value; + displacement = negativeDisplacement ? -(long)Value : (long)Value; } } else @@ -590,7 +590,7 @@ int Get_Nbits_Mem_Operand(string token2) #endregion } - private static int FindEndNextWord(string str, int begin) + private static int FindEndNextWord_UNUSED(string str, int begin) { for (int i = begin; i < str.Length; ++i) { @@ -605,7 +605,7 @@ private static int FindEndNextWord(string str, int begin) public static string GetKeyword(int pos, string line) { - (int beginPos, int endPos) = AsmSourceTools.GetKeywordPos(pos, line); + (int beginPos, int endPos) = GetKeywordPos(pos, line); return line.Substring(beginPos, endPos - beginPos); } @@ -632,7 +632,7 @@ public static string GetPreviousKeyword(int begin, int end, string line) // find the end of current keyword; i.e. read until a separator while (pos >= begin) { - if (AsmTools.AsmSourceTools.IsSeparatorChar(line[pos])) + if (IsSeparatorChar(line[pos])) { //Debug.WriteLine(string.Format("INFO: getPreviousKeyword; line=\"{0}\"; pos={1} has a separator. Found end of current keyword", line, pos)); pos--; @@ -649,7 +649,7 @@ public static string GetPreviousKeyword(int begin, int end, string line) int endPrevious = begin; while (pos >= begin) { - if (AsmTools.AsmSourceTools.IsSeparatorChar(line[pos])) + if (IsSeparatorChar(line[pos])) { //Debug.WriteLine(string.Format("INFO: getPreviousKeyword; line=\"{0}\"; pos={1} has a separator.", line, pos)); pos--; @@ -667,7 +667,7 @@ public static string GetPreviousKeyword(int begin, int end, string line) int beginPrevious = begin; // set the begin of the previous keyword to the begin of search window, such that if no separator is found this will be the begin while (pos >= begin) { - if (AsmTools.AsmSourceTools.IsSeparatorChar(line[pos])) + if (IsSeparatorChar(line[pos])) { beginPrevious = pos + 1; //Debug.WriteLine(string.Format("INFO: getPreviousKeyword; line=\"{0}\"; beginPrevious={1}; pos={2}", line, beginPrevious, pos)); @@ -706,7 +706,7 @@ public static (int BeginPos, int EndPos) GetKeywordPos(int pos, string line) for (int i1 = pos - 1; i1 >= 0; --i1) { char c = line[i1]; - if (AsmSourceTools.IsSeparatorChar(c) || Char.IsControl(c) || AsmSourceTools.IsRemarkChar(c)) + if (IsSeparatorChar(c) || Char.IsControl(c) || IsRemarkChar(c)) { beginPos = i1 + 1; break; @@ -717,7 +717,7 @@ public static (int BeginPos, int EndPos) GetKeywordPos(int pos, string line) for (int i2 = pos; i2 < line.Length; ++i2) { char c = line[i2]; - if (AsmSourceTools.IsSeparatorChar(c) || Char.IsControl(c) || AsmSourceTools.IsRemarkChar(c)) + if (IsSeparatorChar(c) || Char.IsControl(c) || IsRemarkChar(c)) { endPos = i2; break; @@ -745,7 +745,7 @@ private static (bool Valid, int BeginPos, int EndPos) GetLabelDefPos_Regular(str for (; i < nChars; ++i) { char c = line[i]; - if (AsmSourceTools.IsRemarkChar(c)) + if (IsRemarkChar(c)) { return (Valid: false, BeginPos: 0, EndPos: 0); } @@ -780,11 +780,11 @@ private static (bool Valid, int BeginPos, int EndPos) GetLabelDefPos_Regular(str return (Valid: true, BeginPos: beginPos, EndPos: i); } } - else if (AsmSourceTools.IsRemarkChar(c)) + else if (IsRemarkChar(c)) { return (Valid: false, BeginPos: 0, EndPos: 0); } - else if (AsmSourceTools.IsSeparatorChar(c)) + else if (IsSeparatorChar(c)) { // found another keyword: labels can only be the first keyword on a line break; @@ -831,7 +831,7 @@ public static (bool Valid, int BeginPos, int EndPos) GetRemarkPos(string line) int nChars = line.Length; for (int i = 0; i < nChars; ++i) { - if (AsmSourceTools.IsRemarkChar(line[i])) + if (IsRemarkChar(line[i])) { return (Valid: true, BeginPos: i, EndPos: nChars); } @@ -907,7 +907,7 @@ private static bool IsTextSeparatorChar(char c) public static string ToStringBin(ulong value, int nBits) { StringBuilder sb = new StringBuilder(); - for (int i = (nBits - 1); i >= 0; --i) + for (int i = nBits - 1; i >= 0; --i) { int bit = (int)((value >> i) & 1); sb.Append(bit); diff --git a/VS/CSHARP/asm-tools-lib/ExpressionEvaluator.cs b/VS/CSHARP/asm-tools-lib/ExpressionEvaluator.cs index c12b108b..9e9cd107 100644 --- a/VS/CSHARP/asm-tools-lib/ExpressionEvaluator.cs +++ b/VS/CSHARP/asm-tools-lib/ExpressionEvaluator.cs @@ -173,7 +173,7 @@ public static (bool Valid, ulong Value, int NBits) Parse_Constant(string str, bo parsedSuccessfully = false; } - int nBits = (parsedSuccessfully) ? AsmSourceTools.NBitsStorageNeeded(value, isNegative) : -1; + int nBits = parsedSuccessfully ? AsmSourceTools.NBitsStorageNeeded(value, isNegative) : -1; return (Valid: parsedSuccessfully, Value: value, NBits: nBits); } diff --git a/VS/CSHARP/asm-tools-lib/Flags.cs b/VS/CSHARP/asm-tools-lib/Flags.cs index e7ca8604..b6af9703 100644 --- a/VS/CSHARP/asm-tools-lib/Flags.cs +++ b/VS/CSHARP/asm-tools-lib/Flags.cs @@ -89,7 +89,7 @@ public static class FlagTools /// Test whether provided flags is a single flag public static bool SingleFlag(Flags flags) { - int intVal = ((int)flags); + int intVal = (int)flags; return (intVal != 0) && ((intVal & (intVal - 1)) == 0); } diff --git a/VS/CSHARP/asm-tools-lib/Mnemonic.cs b/VS/CSHARP/asm-tools-lib/Mnemonic.cs index 468c0c59..9e1d153e 100644 --- a/VS/CSHARP/asm-tools-lib/Mnemonic.cs +++ b/VS/CSHARP/asm-tools-lib/Mnemonic.cs @@ -2504,7 +2504,7 @@ public static bool IsJump(Mnemonic mnemonic) { /// Parse the provided string that contains a AT&T syntax mnemonic public static Mnemonic ParseMnemonic_Att(string str, bool strIsCapitals = false) { - string str2 = (strIsCapitals) ? str : str.ToUpper(); + string str2 = strIsCapitals ? str : str.ToUpper(); Mnemonic r = ParseMnemonic(str2, true); if (r != Mnemonic.NONE) return r; @@ -2524,7 +2524,7 @@ public static Mnemonic ParseMnemonic_Att(string str, bool strIsCapitals = false) if (suffix) { string keyword2 = str.Substring(0, length - 1); - return AsmSourceTools.ParseMnemonic(keyword2, true); + return ParseMnemonic(keyword2, true); } return Mnemonic.NONE; } diff --git a/VS/CSHARP/asm-tools-lib/Operand.cs b/VS/CSHARP/asm-tools-lib/Operand.cs index a8de7ac7..ec2fcdb1 100644 --- a/VS/CSHARP/asm-tools-lib/Operand.cs +++ b/VS/CSHARP/asm-tools-lib/Operand.cs @@ -45,7 +45,7 @@ public Operand(string token, bool isCapitals, AsmParameters p = null) this._str = token; //TODO: properly handle optional elements {K}{Z} {AES}{ER} - string token2 = (token.Contains("{")) + string token2 = token.Contains("{") ? token. Replace("{K0}", ""). Replace("{K1}", ""). @@ -123,7 +123,7 @@ public void SignExtend(int nBits) { for (int bit = this.NBits; bit < nBits; ++bit) { - this._imm |= (1ul << bit); + this._imm |= 1ul << bit; } } else { diff --git a/VS/CSHARP/asm-tools-lib/RegisterTools.cs b/VS/CSHARP/asm-tools-lib/RegisterTools.cs index b7e750ec..aeb26d6e 100644 --- a/VS/CSHARP/asm-tools-lib/RegisterTools.cs +++ b/VS/CSHARP/asm-tools-lib/RegisterTools.cs @@ -35,10 +35,10 @@ public static class RegisterTools { public static (bool Valid, Rn Reg, int NBits) ToRn(string str, bool isCapitals = false) { - Rn rn = RegisterTools.ParseRn(str, isCapitals); + Rn rn = ParseRn(str, isCapitals); return (rn == Rn.NOREG) ? (Valid: false, Reg: Rn.NOREG, NBits: 0) - : (Valid: true, Reg: rn, NBits: RegisterTools.NBits(rn)); + : (Valid: true, Reg: rn, NBits: NBits(rn)); } public static Rn ParseRn(string str, bool isCapitals = false) @@ -47,7 +47,7 @@ public static Rn ParseRn(string str, bool isCapitals = false) if (isCapitals && (str != str.ToUpper())) throw new Exception(); #endif - switch ((isCapitals) ? str : str.ToUpper()) + switch (isCapitals ? str : str.ToUpper()) { case "RAX": return Rn.RAX; case "EAX": return Rn.EAX; @@ -752,7 +752,7 @@ private static bool IsNumber(char c) public static bool IsRegister(string keyword, bool strIsCapitals = false) { - return RegisterTools.ParseRn(keyword, strIsCapitals) != Rn.NOREG; + return ParseRn(keyword, strIsCapitals) != Rn.NOREG; } public static RegisterType GetRegisterType(Rn rn) diff --git a/VS/CSHARP/unit-tests-asm-sim/TestTools.cs b/VS/CSHARP/unit-tests-asm-sim/TestTools.cs index a16105ba..c2bc7ddf 100644 --- a/VS/CSHARP/unit-tests-asm-sim/TestTools.cs +++ b/VS/CSHARP/unit-tests-asm-sim/TestTools.cs @@ -22,7 +22,7 @@ public static ulong RandUlong(int nBits, Random rand) ulong i1 = (ulong)rand.Next(); if (nBits < 32) { - return (i1 & ((1UL << nBits) - 1)); + return i1 & ((1UL << nBits) - 1); } else { @@ -30,7 +30,7 @@ public static ulong RandUlong(int nBits, Random rand) if (nBits < 63) { ulong r = (i1 << 31) | i2; - return (r & ((1UL << nBits) - 1)); + return r & ((1UL << nBits) - 1); } else { @@ -43,7 +43,7 @@ public static ulong RandUlong(int nBits, Random rand) else { ulong r = (i1 << 33) | (i2 << 2) | (i3 & 0x3); - return (r & ((1UL << nBits) - 1)); + return r & ((1UL << nBits) - 1); } } } @@ -51,12 +51,12 @@ public static ulong RandUlong(int nBits, Random rand) public static long RandLong(int nBits, Random rand) { ulong raw = RandUlong(nBits, rand); - bool sign = ((raw & (1UL << (nBits - 1))) != 0); + bool sign = (raw & (1UL << (nBits - 1))) != 0; if (sign) { for (int i = nBits; i < 64; ++i) { - raw |= (1UL << i); + raw |= 1UL << i; } } return (long)raw; @@ -64,7 +64,7 @@ public static long RandLong(int nBits, Random rand) public static Tv ToTv5(bool b) { - return (b) ? Tv.ONE : Tv.ZERO; + return b ? Tv.ONE : Tv.ZERO; } #region Calculate Flags @@ -74,7 +74,7 @@ public static bool Calc_OF_Add(uint nBits, ulong a, ulong b) bool signB = Calc_SF(nBits, b); ulong c = a + b; bool signC = Calc_SF(nBits, c); - bool result = ((signA == signB) && (signA != signC)); + bool result = (signA == signB) && (signA != signC); //Console.WriteLine("TestTools: calc_OF_Add: nBits="+nBits+"; a=" + a + "; b=" + b + "; c=" + c + "; signA=" + signA + "; signB=" + signB + "; signC=" + signC +"; result="+result); return result; } @@ -84,7 +84,7 @@ public static bool Calc_OF_Sub(uint nBits, ulong a, ulong b) bool signB = Calc_SF(nBits, b); ulong c = a - b; bool signC = Calc_SF(nBits, c); - bool result = ((signA == signB) && (signA != signC)); + bool result = (signA == signB) && (signA != signC); //Console.WriteLine("TestTools: calc_OF_Add: nBits="+nBits+"; a=" + a + "; b=" + b + "; c=" + c + "; signA=" + signA + "; signB=" + signB + "; signC=" + signC +"; result="+result); return result; } @@ -198,13 +198,13 @@ public static Tv GetTv5(Flags flag, State state) } public static void AreEqual(Flags flags, bool expected, State state) { - TestTools.AreEqual(flags, (expected) ? Tv.ONE : Tv.ZERO, state); + AreEqual(flags, expected ? Tv.ONE : Tv.ZERO, state); } public static void AreEqual(Flags flags, Tv expected, State state) { foreach (Flags flag in FlagTools.GetFlags(flags)) { - TestTools.AreEqual(expected, state.GetTv(flag)); + AreEqual(expected, state.GetTv(flag)); } } #endregion @@ -212,18 +212,18 @@ public static void AreEqual(Flags flags, Tv expected, State state) #region AreEqual Register public static void AreEqual(Rn name, int expected, State state) { - TestTools.AreEqual(name, (ulong)expected, state); + AreEqual(name, (ulong)expected, state); } public static void AreEqual(Rn name, ulong expected, State state) { Tv[] expectedTvArray = ToolsZ3.GetTvArray(expected, RegisterTools.NBits(name)); - TestTools.AreEqual(name, expectedTvArray, state); + AreEqual(name, expectedTvArray, state); } public static void AreEqual(Rn name, string expected, State state) { Tv[] expectedTvArray = ToolsZ3.GetTvArray(expected); Assert.AreEqual(RegisterTools.NBits(name), expectedTvArray.Length); - TestTools.AreEqual(name, expectedTvArray, state); + AreEqual(name, expectedTvArray, state); } public static void AreEqual(Rn name, Tv[] expectedTvArray, State state) { @@ -244,7 +244,7 @@ public static void AreEqual(Rn name, Tv[] expectedTvArray, State state) } else { - TestTools.AreEqual(expectedTvArray, actualTvArray); + AreEqual(expectedTvArray, actualTvArray); } } /// @@ -308,13 +308,13 @@ public static void AreEqual(BitVecExpr expr, ulong expected, State state) { Tv[] expectedTvArray = ToolsZ3.GetTvArray(expected, (int)expr.SortSize); Assert.IsNotNull(expectedTvArray); - TestTools.AreEqual(expr, expectedTvArray, state); + AreEqual(expr, expectedTvArray, state); } public static void AreEqual(BitVecExpr expr, string expected, State state) { Tv[] expectedTvArray = ToolsZ3.GetTvArray(expected); Assert.AreEqual(expr.SortSize, (uint)expectedTvArray.Length); - TestTools.AreEqual(expr, expectedTvArray, state); + AreEqual(expr, expectedTvArray, state); } public static void AreEqual(BitVecExpr expr, Tv[] expectedTvArray, State state) { @@ -344,7 +344,7 @@ public static void AreEqual(BitVecExpr expr, Tv[] expectedTvArray, State state) #region AreEqual TV public static void AreEqual(ulong expected, Tv[] actualArray) { - TestTools.AreEqual(ToolsZ3.GetTvArray(expected, actualArray.Length), actualArray); + AreEqual(ToolsZ3.GetTvArray(expected, actualArray.Length), actualArray); } public static void AreEqual(Tv[] expectedArray, Tv[] actualArray) { diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs b/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs index e9f38ddc..fe783b25 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_BitTricks.cs @@ -423,10 +423,10 @@ public void Test_BitTricks_Parallel_Search_GPR_1() Context ctx = state.Ctx; BitVecExpr zero = ctx.MkBV(0, 8); bytes = bytes.Translate(ctx) as BitVecExpr; - BitVecExpr byte1 = ctx.MkExtract((1 * 8) - 1, (0 * 8), bytes); - BitVecExpr byte2 = ctx.MkExtract((2 * 8) - 1, (1 * 8), bytes); - BitVecExpr byte3 = ctx.MkExtract((3 * 8) - 1, (2 * 8), bytes); - BitVecExpr byte4 = ctx.MkExtract((4 * 8) - 1, (3 * 8), bytes); + BitVecExpr byte1 = ctx.MkExtract((1 * 8) - 1, 0 * 8, bytes); + BitVecExpr byte2 = ctx.MkExtract((2 * 8) - 1, 1 * 8, bytes); + BitVecExpr byte3 = ctx.MkExtract((3 * 8) - 1, 2 * 8, bytes); + BitVecExpr byte4 = ctx.MkExtract((4 * 8) - 1, 3 * 8, bytes); { // if at least one of the bytes is equal to zero, then ECX cannot be equal to zero @@ -514,14 +514,14 @@ public void Test_BitTricks_Parallel_Search_GPR_2() BitVecExpr zero8 = ctx.MkBV(0, 8); bytes = bytes.Translate(ctx) as BitVecExpr; - BitVecExpr byte1 = ctx.MkExtract((1 * 8) - 1, (0 * 8), bytes); - BitVecExpr byte2 = ctx.MkExtract((2 * 8) - 1, (1 * 8), bytes); - BitVecExpr byte3 = ctx.MkExtract((3 * 8) - 1, (2 * 8), bytes); - BitVecExpr byte4 = ctx.MkExtract((4 * 8) - 1, (3 * 8), bytes); - BitVecExpr byte5 = ctx.MkExtract((5 * 8) - 1, (4 * 8), bytes); - BitVecExpr byte6 = ctx.MkExtract((6 * 8) - 1, (5 * 8), bytes); - BitVecExpr byte7 = ctx.MkExtract((7 * 8) - 1, (6 * 8), bytes); - BitVecExpr byte8 = ctx.MkExtract((8 * 8) - 1, (7 * 8), bytes); + BitVecExpr byte1 = ctx.MkExtract((1 * 8) - 1, 0 * 8, bytes); + BitVecExpr byte2 = ctx.MkExtract((2 * 8) - 1, 1 * 8, bytes); + BitVecExpr byte3 = ctx.MkExtract((3 * 8) - 1, 2 * 8, bytes); + BitVecExpr byte4 = ctx.MkExtract((4 * 8) - 1, 3 * 8, bytes); + BitVecExpr byte5 = ctx.MkExtract((5 * 8) - 1, 4 * 8, bytes); + BitVecExpr byte6 = ctx.MkExtract((6 * 8) - 1, 5 * 8, bytes); + BitVecExpr byte7 = ctx.MkExtract((7 * 8) - 1, 6 * 8, bytes); + BitVecExpr byte8 = ctx.MkExtract((8 * 8) - 1, 7 * 8, bytes); BoolExpr property = ctx.MkEq( ctx.MkOr( diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_FlagTools.cs b/VS/CSHARP/unit-tests-asm-sim/Test_FlagTools.cs index de822fce..7f47941a 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_FlagTools.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_FlagTools.cs @@ -48,7 +48,7 @@ public void Test_FlagTools_Create_OF_Add() BitVecExpr bExpr = ctx.MkBV(b, nBits); BoolExpr resultExpr = ToolsFlags.Create_OF_Add(aExpr, bExpr, nBits, ctx).Simplify() as BoolExpr; - Assert.IsTrue((TestTools.Calc_OF_Add(nBits, a, b) ? resultExpr.IsTrue : resultExpr.IsFalse)); + Assert.IsTrue(TestTools.Calc_OF_Add(nBits, a, b) ? resultExpr.IsTrue : resultExpr.IsFalse); } ctx.Dispose(); } diff --git a/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs b/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs index 7b868541..c0ec4062 100644 --- a/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs +++ b/VS/CSHARP/unit-tests-asm-sim/Test_Mnemonic.cs @@ -1003,7 +1003,7 @@ public void Test_MnemonicZ3_Add_2() { ulong rax_value = TestTools.RandUlong((int)nBits, rand); ulong rbx_value = TestTools.RandUlong((int)nBits, rand); - ulong result = (rax_value + rbx_value); + ulong result = rax_value + rbx_value; State state = this.CreateState(tools); Context ctx = state.Ctx; @@ -2218,7 +2218,7 @@ public void Test_MnemonicZ3_Imul_8bits_1() sbyte al = 0b0000_0100; sbyte bl = 0b0000_0100; - short ax = (short)((int)al * (int)bl); + short ax = (short)(al * bl); string line1 = "mov al, " + al; string line2 = "mov bl, " + bl; @@ -2249,7 +2249,7 @@ public void Test_MnemonicZ3_Imul_8bits_2() sbyte al = 0b0100_0000; sbyte bl = 0b0010_0000; - short ax = (short)((int)al * (int)bl); + short ax = (short)(al * bl); string line1 = "mov al, " + al; string line2 = "mov bl, " + bl; @@ -2280,7 +2280,7 @@ public void Test_MnemonicZ3_Imul_8bits_3() sbyte al = unchecked((sbyte)0b1000_0000); sbyte bl = 0b0010_0000; - short ax = (short)((int)al * (int)bl); + short ax = (short)(al * bl); string line1 = "mov al, " + al; string line2 = "mov bl, " + bl; @@ -2312,7 +2312,7 @@ public void Test_MnemonicZ3_Imul_16bits_1() short ax = -16; short bx = 22; - int result = (int)((int)ax * (int)bx); + int result = ax * bx; ulong resultAx = ((ulong)result) & 0xFFFF; ulong resultDx = ((ulong)result >> 16) & 0xFFFF; @@ -2377,7 +2377,7 @@ public void Test_MnemonicZ3_Imul_16bits_2() short ax = 0b0100_0000_0000_0000; // large positive short bx = -0b0110_0000_0000_0000; // large negative - int result = (int)((int)ax * (int)bx); + int result = ax * bx; ulong resultAx = ((ulong)result) & 0xFFFF; ulong resultDx = ((ulong)result >> 16) & 0xFFFF; @@ -2447,7 +2447,7 @@ public void Test_MnemonicZ3_Imul_32bits_1() int eax = 0b0100_0000_0000_0000; int ebx = -0b0110_0000_0000_0000; - long result = (int)((int)eax * (int)ebx); + long result = eax * ebx; ulong resultEax = ((ulong)result) & 0xFFFF_FFFF; ulong resultEdx = ((ulong)result >> 32) & 0xFFFF_FFFF; @@ -2517,7 +2517,7 @@ public void Test_MnemonicZ3_Imul_32bits_2() int eax = 0b0100_0000_0000_0000_0000_0000_0000_0000; // large positive int ebx = -0b0110_0000_0000_0000_0100_0000_0000_0000; // large negative - long result = (long)eax * (long)ebx; + long result = eax * (long)ebx; ulong resultEax = ((ulong)result) & 0xFFFF_FFFF; ulong resultEdx = ((ulong)result >> 32) & 0xFFFF_FFFF; @@ -2808,9 +2808,9 @@ public void Test_MnemonicZ3_Div_16bits_1() UInt16 ax = 0b0000_0011_0100_0000; UInt16 bx = 0b0000_0000_0100_0000; - UInt32 value = (((UInt32)dx) << 16) | (UInt32)ax; - UInt16 quotient = (UInt16)(value / (UInt32)bx); - UInt16 remainder = (UInt16)(value % (UInt32)bx); + UInt32 value = (((UInt32)dx) << 16) | ax; + UInt16 quotient = (UInt16)(value / bx); + UInt16 remainder = (UInt16)(value % bx); string line1 = "mov ax, " + ax; string line2 = "mov dx, " + dx; @@ -2851,9 +2851,9 @@ public void Test_MnemonicZ3_Div_32bits_1() UInt32 eax = 0b0000_0000_0000_0000_0000_0011_0100_0000; UInt32 ebx = 0b0000_0000_0000_1000_0000_0000_0100_0000; - UInt64 value = (((UInt64)edx) << 32) | (UInt64)eax; - UInt32 quotient = (UInt32)(value / (UInt64)ebx); - UInt32 remainder = (UInt32)(value % (UInt64)ebx); + UInt64 value = (((UInt64)edx) << 32) | eax; + UInt32 quotient = (UInt32)(value / ebx); + UInt32 remainder = (UInt32)(value % ebx); string line1 = "mov eax, " + eax; string line2 = "mov edx, " + edx; @@ -2869,8 +2869,8 @@ public void Test_MnemonicZ3_Div_32bits_1() state = Runner.SimpleStep_Forward(line4, state); if (logToDisplay) Console.WriteLine("After \"" + line4 + "\", we know:\n" + state); - TestTools.AreEqual(Rn.EAX, (ulong)quotient, state); - TestTools.AreEqual(Rn.EDX, (ulong)remainder, state); + TestTools.AreEqual(Rn.EAX, quotient, state); + TestTools.AreEqual(Rn.EDX, remainder, state); TestTools.AreEqual(Flags.AF | Flags.SF | Flags.ZF | Flags.PF | Flags.CF | Flags.OF, Tv.UNDEFINED, state); } } @@ -3325,7 +3325,7 @@ public void Test_MnemonicZ3_Daa_1() int byteA_2 = 3; int byteB_1 = 2; int byteB_2 = 1; - int result = (((byteA_2 + byteB_2) << 4) | ((byteA_1 + byteB_1) << 0)); + int result = ((byteA_2 + byteB_2) << 4) | ((byteA_1 + byteB_1) << 0); string line1 = "mov eax, " + ((byteA_2 << 4) | (byteA_1 << 0)); string line2 = "add eax, " + ((byteB_2 << 4) | (byteB_1 << 0)); @@ -3353,7 +3353,7 @@ public void Test_MnemonicZ3_Daa_2() int byteA_2 = 3; int byteB_1 = 3; int byteB_2 = 1; - int result = (((byteA_2 + byteB_2 + 1) << 4) | (1 << 0)); + int result = ((byteA_2 + byteB_2 + 1) << 4) | (1 << 0); string line1 = "mov eax, " + ((byteA_2 << 4) | (byteA_1 << 0)); string line2 = "add eax, " + ((byteB_2 << 4) | (byteB_1 << 0)); @@ -3387,7 +3387,7 @@ public void Test_MnemonicZ3_Das_1() int byteA_2 = 3; int byteB_1 = 2; int byteB_2 = 1; - int result = (((byteA_2 - byteB_2) << 4) | ((byteA_1 - byteB_1) << 0)); + int result = ((byteA_2 - byteB_2) << 4) | ((byteA_1 - byteB_1) << 0); string line1 = "mov eax, " + ((byteA_2 << 4) | (byteA_1 << 0)); string line2 = "sub eax, " + ((byteB_2 << 4) | (byteB_1 << 0)); @@ -3778,7 +3778,7 @@ public void Test_MnemonicZ3_Aad_Base10_2() //32 / 2 = 16 int byteA_2 = 3; int byteA_1 = 2; - int decimalA = ((byteA_2 * 10) + byteA_1); + int decimalA = (byteA_2 * 10) + byteA_1; int byteD_1 = 2; int result = decimalA / byteD_1; diff --git a/VS/CSHARP/unit-tests-asm-tools/test_AsmSourceTools.cs b/VS/CSHARP/unit-tests-asm-tools/test_AsmSourceTools.cs index d1df06af..6630ab8a 100644 --- a/VS/CSHARP/unit-tests-asm-tools/test_AsmSourceTools.cs +++ b/VS/CSHARP/unit-tests-asm-tools/test_AsmSourceTools.cs @@ -36,25 +36,25 @@ public class Test_AsmSourceTools { private static ulong RandUlong(int nBits, Random rand) { ulong i1 = (ulong)rand.Next(); if (nBits < 32) { - return (i1 & ((1UL << nBits) - 1)); + return i1 & ((1UL << nBits) - 1); } else { ulong i2 = (ulong)rand.Next(); if (nBits < 63) { ulong r = (i1 << 31) | i2; - return (r & ((1UL << nBits) - 1)); + return r & ((1UL << nBits) - 1); } else { ulong i3 = (ulong)rand.Next(); ulong r = (i1 << 33) | (i2 << 2) | (i3 & 0x3); - return (r & ((1UL << nBits) - 1)); + return r & ((1UL << nBits) - 1); } } } private static long RandLong(int nBits, Random rand) { ulong raw = RandUlong(nBits, rand); - bool sign = ((raw & (1UL << (nBits - 1))) != 0); + bool sign = (raw & (1UL << (nBits - 1))) != 0; if (sign) { for (int i = nBits; i < 64; ++i) { - raw |= (1UL << i); + raw |= 1UL << i; } } return (long)raw; @@ -95,42 +95,42 @@ public void Test_AsmSourceTools_GetPreviousKeyword() { { int begin = 0; int end = 8; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("mov", result, msg); } { int begin = 4; int end = 8; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("mov", result, msg); } { int begin = 5; int end = 8; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("ov", result, msg); } { int begin = 0; int end = 7; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("mov", result, msg); } { int begin = 0; int end = 6; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("", result, msg); } { int begin = 0; int end = 11; - string result = AsmTools.AsmSourceTools.GetPreviousKeyword(begin, end, line); + string result = AsmSourceTools.GetPreviousKeyword(begin, end, line); string msg = "line=\"" + line + "\"; result=\"" + result + "\"; begin=" + begin + "; end=" + end; Assert.AreEqual("rax", result, msg); } @@ -309,14 +309,14 @@ public void Test_AsmSourceTools_Evaluate_2() [TestMethod] public void Test_AsmSourceTools_parseMnemonic() { foreach (Mnemonic x in Enum.GetValues(typeof(Mnemonic))) { - Assert.AreEqual(AsmTools.AsmSourceTools.ParseMnemonic(x.ToString()), x, + Assert.AreEqual(AsmSourceTools.ParseMnemonic(x.ToString()), x, "Parsing string " + x.ToString() + " does not yield the same enumeration."); } } [TestMethod] public void Test_AsmSourceTools_parseArch() { foreach (Arch x in Enum.GetValues(typeof(Arch))) { - Assert.AreEqual(AsmTools.ArchTools.ParseArch(ArchTools.ToString(x)), x, + Assert.AreEqual(ArchTools.ParseArch(ArchTools.ToString(x)), x, "Parsing string " + x.ToString() + " does not yield the same enumeration."); } }