Skip to content

Commit

Permalink
minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HJLebbink committed Sep 29, 2019
1 parent 438fa3f commit 064a924
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 105 deletions.
80 changes: 43 additions & 37 deletions VS/CSHARP/asm-dude-vsix/OptionsPage/AsmDudeOptionPageUI.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 H.J. Lebbink
// Copyright (c) 2019 Henk-Jan Lebbink
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

namespace AsmDude.OptionsPage
{
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Windows.Controls;
using AsmDude.Tools;
Expand Down Expand Up @@ -71,13 +71,17 @@ public object GetPropValue(string propName)

public void SetPropValue(string propName, object o)
{
try
if (o != null)
{
this.GetType().GetProperty(propName).SetValue(this, o);
}
catch (Exception e)
{
AsmDudeToolsStatic.Output_ERROR("Could not find property " + propName + "; " + e);
try
{
//AsmDudeToolsStatic.Output_INFO(string.Format("{0}:SetPropValue: propName={1}; o={2}", this.ToString(), propName, o.ToString()));
this.GetType().GetProperty(propName).SetValue(this, o);
}
catch (Exception e)
{
AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:SetPropValue: Could not find property={1}; o={2}", this.ToString(), propName, o.ToString()));
}
}
}

Expand Down Expand Up @@ -160,25 +164,12 @@ private void AsmSim_Update(bool value)
#region Global
public int Global_MaxFileLines
{
get { return this.Global_MaxFileLines_UI.Value ?? 50000; }
get { return this.Global_MaxFileLines_UI.Value.GetValueOrDefault(); }
set { this.Global_MaxFileLines_UI.Value = value; }
}
#endregion

#region Asm Documentation
public bool AsmDoc_On
{
get { return this.AsmDoc_On_UI.IsChecked ?? false; }
set { this.AsmDoc_On_UI.IsChecked = value; }
}

public string AsmDoc_Url
{
get { return this.AsmDoc_Url_UI.Text; }
set { this.AsmDoc_Url_UI.Text = value; }
}
#endregion Asm Documentation

#region Assembly Flavour
public AssemblerEnum UsedAssembler
{
get
Expand Down Expand Up @@ -279,8 +270,23 @@ public AssemblerEnum UsedAssemblerDisassemblyWindow
}
}
}
#endregion

#region AsmDoc
public bool AsmDoc_On
{
get { return this.AsmDoc_On_UI.IsChecked ?? false; }
set { this.AsmDoc_On_UI.IsChecked = value; }
}

public string AsmDoc_Url
{
get { return this.AsmDoc_Url_UI.Text; }
set { this.AsmDoc_Url_UI.Text = value; }
}
#endregion Asm Documentation

#region Code Folding
#region CodeFolding
public bool CodeFolding_On
{
get { return this.CodeFolding_On_UI.IsChecked ?? false; }
Expand Down Expand Up @@ -1062,7 +1068,7 @@ public bool IntelliSense_Decorate_Undefined_Includes
}
#endregion

#region Assembly Simulator
#region AsmSim
public bool AsmSim_On
{
get { return this.AsmSim_On_UI.IsChecked ?? false; }
Expand All @@ -1071,13 +1077,13 @@ public bool AsmSim_On

public int AsmSim_Z3_Timeout_MS
{
get { return this.AsmSim_Z3_Timeout_MS_UI.Value ?? 100; }
get { return this.AsmSim_Z3_Timeout_MS_UI.Value.GetValueOrDefault(); }
set { this.AsmSim_Z3_Timeout_MS_UI.Value = value; }
}

public int AsmSim_Number_Of_Threads
{
get { return this.AsmSim_Number_Of_Threads_UI.Value ?? 4; }
get { return this.AsmSim_Number_Of_Threads_UI.Value.GetValueOrDefault(); }
set { this.AsmSim_Number_Of_Threads_UI.Value = value; }
}

Expand Down
20 changes: 12 additions & 8 deletions VS/CSHARP/asm-dude-vsix/OptionsPage/AsmDudeOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace AsmDude.OptionsPage
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

public enum PropertyEnum
public enum PropertyEnum // NOTE: the enum elements should be precisely equal to the keys in Settings
{
Global_MaxFileLines,

Expand Down Expand Up @@ -371,11 +371,15 @@ protected override void OnActivate(CancelEventArgs e)
{
base.OnActivate(e);

this._asmDudeOptionsPageUI.UsedAssembler = AsmDudeToolsStatic.Used_Assembler;
this._asmDudeOptionsPageUI.UsedAssemblerDisassemblyWindow = AsmDudeToolsStatic.Used_Assembler_Disassembly_Window;

#region Global
this.Set_GUI(PropertyEnum.Global_MaxFileLines);
//TODO: 29-09-19 why o why need i set DisplayDefaultValueOnEmptyText to true, while this is not necessary for AsmSim_Number_Of_Threads and AsmSim_Z3_Timeout_MS
this._asmDudeOptionsPageUI.Global_MaxFileLines_UI.DisplayDefaultValueOnEmptyText = true;
#endregion

#region Assembly Flavour
this._asmDudeOptionsPageUI.UsedAssembler = AsmDudeToolsStatic.Used_Assembler;
this._asmDudeOptionsPageUI.UsedAssemblerDisassemblyWindow = AsmDudeToolsStatic.Used_Assembler_Disassembly_Window;
#endregion

#region AsmDoc
Expand Down Expand Up @@ -472,13 +476,13 @@ protected override void OnActivate(CancelEventArgs e)
this.Set_GUI(PropertyEnum.AsmSim_Decorate_Unreachable_Instructions);
this.Set_GUI(PropertyEnum.AsmSim_Decorate_Registers);
this.Set_GUI(PropertyEnum.AsmSim_Show_Register_In_Code_Completion);
//TODO
//TODO: create generic ParseNumeration
this._asmDudeOptionsPageUI.AsmSim_Show_Register_In_Code_Completion_Numeration = AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Code_Completion_Numeration);
this.Set_GUI(PropertyEnum.AsmSim_Show_Register_In_Register_Tooltip);
//TODO
//TODO: create generic ParseNumeration
this._asmDudeOptionsPageUI.AsmSim_Show_Register_In_Register_Tooltip_Numeration = AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Register_Tooltip_Numeration);
this.Set_GUI(PropertyEnum.AsmSim_Show_Register_In_Instruction_Tooltip);
//TODO
//TODO: create generic ParseNumeration
this._asmDudeOptionsPageUI.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration = AsmSourceTools.ParseNumeration(Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration);
this.Set_GUI(PropertyEnum.AsmSim_Decorate_Unimplemented);
this.Set_GUI(PropertyEnum.AsmSim_Pragma_Assume);
Expand Down Expand Up @@ -789,7 +793,7 @@ private async System.Threading.Tasks.Task SaveAsync()
restartNeeded = true;
}
#endregion
if (this.Setting_Update(PropertyEnum.CodeFolding_On)) { changed = true; restartNeeded = true; }

#region AsmDoc
if (this.Setting_Update(PropertyEnum.AsmDoc_On)) { changed = true; }
if (this.Setting_Update(PropertyEnum.AsmDoc_Url)) { changed = true; restartNeeded = true; }
Expand Down
116 changes: 58 additions & 58 deletions VS/CSHARP/asm-dude-vsix/Tools/AsmDudeToolsStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,61 +84,6 @@ public static void Print_Speed_Warning(DateTime startTime, string component)

#endregion Singleton Factories

public static AssemblerEnum Used_Assembler
{
get
{
if (Settings.Default.useAssemblerAutoDetect)
{
return AssemblerEnum.AUTO_DETECT;
}
if (Settings.Default.useAssemblerMasm)
{
return AssemblerEnum.MASM;
}
if (Settings.Default.useAssemblerNasm)
{
return AssemblerEnum.NASM_INTEL;
}
if (Settings.Default.useAssemblerNasm_Att)
{
return AssemblerEnum.NASM_ATT;
}
Output_WARNING("AsmDudeToolsStatic.Used_Assembler: no assembler specified, assuming AUTO_DETECT");
return AssemblerEnum.AUTO_DETECT;
}

set
{
Settings.Default.useAssemblerAutoDetect = false;
Settings.Default.useAssemblerMasm = false;
Settings.Default.useAssemblerNasm = false;
Settings.Default.useAssemblerNasm_Att = false;

if (value.HasFlag(AssemblerEnum.AUTO_DETECT))
{
Settings.Default.useAssemblerAutoDetect = true;
}
if (value.HasFlag(AssemblerEnum.MASM))
{
Settings.Default.useAssemblerMasm = true;
}
else if (value.HasFlag(AssemblerEnum.NASM_INTEL))
{
Settings.Default.useAssemblerNasm = true;
}
else if (value.HasFlag(AssemblerEnum.NASM_ATT))
{
Settings.Default.useAssemblerNasm_Att = true;
}
else
{
Output_WARNING("AsmDudeToolsStatic.Used_Assembler: no assembler specified, assuming AUTO_DETECT");
Settings.Default.useAssemblerAutoDetect = true;
}
}
}

/// <summary>Guess whether the provided buffer has assembly in Intel syntax (return true) or AT&T syntax (return false)</summary>
public static bool Guess_Intel_Syntax(ITextBuffer buffer, int nLinesMax = 30)
{
Expand Down Expand Up @@ -302,6 +247,61 @@ public static int MaxFileLines
}
}

public static AssemblerEnum Used_Assembler
{
get
{
if (Settings.Default.useAssemblerAutoDetect)
{
return AssemblerEnum.AUTO_DETECT;
}
if (Settings.Default.useAssemblerMasm)
{
return AssemblerEnum.MASM;
}
if (Settings.Default.useAssemblerNasm)
{
return AssemblerEnum.NASM_INTEL;
}
if (Settings.Default.useAssemblerNasm_Att)
{
return AssemblerEnum.NASM_ATT;
}
Output_WARNING("AsmDudeToolsStatic.Used_Assembler:get: no assembler specified, assuming AUTO_DETECT");
return AssemblerEnum.AUTO_DETECT;
}

set
{
Settings.Default.useAssemblerAutoDetect = false;
Settings.Default.useAssemblerMasm = false;
Settings.Default.useAssemblerNasm = false;
Settings.Default.useAssemblerNasm_Att = false;

if (value.HasFlag(AssemblerEnum.AUTO_DETECT))
{
Settings.Default.useAssemblerAutoDetect = true;
}
else if (value.HasFlag(AssemblerEnum.MASM))
{
Settings.Default.useAssemblerMasm = true;
}
else if (value.HasFlag(AssemblerEnum.NASM_INTEL))
{
Settings.Default.useAssemblerNasm = true;
}
else if (value.HasFlag(AssemblerEnum.NASM_ATT))
{
Settings.Default.useAssemblerNasm_Att = true;
}
else
{
Output_WARNING(string.Format("{0}:Used_Assembler:set: no assembler specified; value={1}, assuming AUTO_DETECT", "AsmDudeToolsStatic", value));
Settings.Default.useAssemblerAutoDetect = true;
}
}
}

public static AssemblerEnum Used_Assembler_Disassembly_Window
{
get
Expand All @@ -318,7 +318,7 @@ public static AssemblerEnum Used_Assembler_Disassembly_Window
{
return AssemblerEnum.NASM_ATT;
}
Output_WARNING("AsmDudeToolsStatic.Used_Assembler_Disassembly_Window: no assembler specified, assuming AUTO_DETECT");
Output_WARNING("AsmDudeToolsStatic.Used_Assembler_Disassembly_Window:get no assembler specified, assuming AUTO_DETECT");
return AssemblerEnum.AUTO_DETECT;
}

Expand All @@ -332,7 +332,7 @@ public static AssemblerEnum Used_Assembler_Disassembly_Window
{
Settings.Default.useAssemblerDisassemblyAutoDetect = true;
}
if (value.HasFlag(AssemblerEnum.MASM))
else if (value.HasFlag(AssemblerEnum.MASM))
{
Settings.Default.useAssemblerDisassemblyMasm = true;
}
Expand All @@ -342,7 +342,7 @@ public static AssemblerEnum Used_Assembler_Disassembly_Window
}
else
{
Output_WARNING("AsmDudeToolsStatic.Used_Assembler_Disassembly_Window: no assembler specified, assuming AUTO_DETECT");
Output_WARNING(string.Format("{0}:Used_Assembler_Disassembly_Window:set: no assembler specified; value={1}, assuming AUTO_DETECT", "AsmDudeToolsStatic", value));
Settings.Default.useAssemblerDisassemblyAutoDetect = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion VS/CSHARP/asm-dude-vsix/source.extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static class Vsix
public const string Name = "AsmDude";
public const string Description = "Syntax highlighting and code assistance for assembly source code (.asm, .cod, .inc, .s) and the Disassembly Window ";
public const string Language = "en-US";
public const string Version = "1.9.6.12";
public const string Version = "1.9.6.14";
public const string Author = "Henk-Jan Lebbink";
public const string Tags = "Assembly, Assembler, ASM, Syntax Highlighting, Code Completion, Disassembly Window, Code Analysis, x86_64, SSE, AVX, AVX2, AVX512";
}
Expand Down
2 changes: 1 addition & 1 deletion VS/CSHARP/asm-dude-vsix/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="c729d6b2-f412-49ed-893d-a8f61f25db98" Version="1.9.6.12" Language="en-US" Publisher="Henk-Jan Lebbink" />
<Identity Id="c729d6b2-f412-49ed-893d-a8f61f25db98" Version="1.9.6.14" Language="en-US" Publisher="Henk-Jan Lebbink" />
<DisplayName>AsmDude</DisplayName>
<Description xml:space="preserve">Syntax highlighting and code assistance for assembly source code (.asm, .cod, .inc, .s) and the Disassembly Window </Description>
<MoreInfo>https://github.com/HJLebbink/asm-dude</MoreInfo>
Expand Down

0 comments on commit 064a924

Please sign in to comment.