diff --git a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/MasmDisassemblyTokenTagger.cs b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/MasmDisassemblyTokenTagger.cs index 25280705..4aac7ba2 100644 --- a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/MasmDisassemblyTokenTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/MasmDisassemblyTokenTagger.cs @@ -148,12 +148,10 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._misc); break; } - default: - { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label); break; } - } + break; } default: @@ -174,6 +172,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical { if (asmToken.Equals("OFFSET")) + { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._directive); k++; // goto the next word @@ -211,13 +210,13 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } default: break; } - } } AsmDudeToolsStatic.Print_Speed_Warning(time1, "MasmDisassemblyTokenTagger"); } #region Private Member Methods + private static bool IsConstant(string token) { if (long.TryParse(token, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var dummy1)) @@ -262,7 +261,9 @@ private static bool IsSourceCode(string line, List<(int BeginPos, int Length, bo } return true; } + #endregion + #region Public Static Methods public static string Keyword((int, int, bool) pos, string line) @@ -274,6 +275,7 @@ public static SnapshotSpan New_Span((int, int, bool) pos, int offset, SnapshotSp { return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.Item1 + offset, pos.Item2 - pos.Item1)); } + #endregion Public Static Methods } } diff --git a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttDisassemblyTokenTagger.cs b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttDisassemblyTokenTagger.cs index e1ade6d0..c82b2902 100644 --- a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttDisassemblyTokenTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttDisassemblyTokenTagger.cs @@ -141,13 +141,15 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti k++; if (k == nKeywords) break; string asmToken3 = NasmIntelTokenTagger.Keyword(pos[k], line); - if (asmToken3.Equals("PTR")) + switch (asmToken3) { - yield return new TagSpan(New_Span(pos[k], offset, curSpan), this._misc); - } - else - { - yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label); + case "PTR": + { + yield return new TagSpan(New_Span(pos[k], offset, curSpan), this._misc); + break; + } + yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._label); + break; } break; } diff --git a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttTokenTagger.cs b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttTokenTagger.cs index 60b6a503..0aad98b4 100644 --- a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttTokenTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmAttTokenTagger.cs @@ -91,7 +91,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti ITextSnapshotLine containingLine = curSpan.Start.GetContainingLine(); string line = containingLine.GetText().ToUpper(); - IList<(int beginPos, int length, bool isLabel)> pos = new List<(int beginPos, int length, bool isLabel)>(AsmSourceTools.SplitIntoKeywordPos(line)); + var pos = new List<(int BeginPos, int Length, bool IsLabel)>(AsmSourceTools.SplitIntoKeywordPos(line)); int offset = containingLine.Start.Position; int nKeywords = pos.Count; @@ -99,6 +99,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti for (int k = 0; k < nKeywords; k++) { string asmToken = NasmIntelTokenTagger.Keyword(pos[k], line); + // keyword starts with a remark char if (AsmSourceTools.IsRemarkChar(asmToken[0])) { @@ -107,7 +108,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } // keyword k is a label definition - if (pos[k].isLabel) + if (pos[k].IsLabel) { //AsmDudeToolsStatic.Output_INFO("NasmTokenTagger:GetTags: found label " +asmToken); if (IsProperLabelDef(asmToken, containingLine.LineNumber, out AsmTokenTag asmTokenTag)) @@ -116,7 +117,6 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti continue; } } - AsmTokenType keywordType = this._asmDudeTools.Get_Token_Type_Att(asmToken); switch (keywordType) { @@ -174,16 +174,14 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical { - //if (AsmTools.AsmSourceTools.Parse_Constant(asmToken, true).Valid) if (AsmSourceTools.Evaluate_Constant(asmToken, true).Valid) + //if (AsmSourceTools.Parse_Constant(asmToken, true).Valid) { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant); - } else if (asmToken.StartsWith("\"") && asmToken.EndsWith("\"")) { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant); - } else { @@ -259,7 +257,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } } } - AsmDudeToolsStatic.Print_Speed_Warning(time1, "AttTokenTagger"); + AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmAttTokenTagger"); } #region Public Static Methods @@ -324,9 +322,9 @@ public static string Keyword((int, int, bool) pos, string line) return line.Substring(pos.Item1, pos.Item2 - pos.Item1); } - public static SnapshotSpan New_Span((int, int, bool) pos, int offset, SnapshotSpan lineSnapShot) + public static SnapshotSpan New_Span((int BeginPos, int Length, bool IsLabel) pos, int offset, SnapshotSpan lineSnapShot) { - return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.Item1 + offset, pos.Item2 - pos.Item1)); + return new SnapshotSpan(lineSnapShot.Snapshot, new Span(pos.BeginPos + offset, pos.Length - pos.BeginPos)); } #endregion Public Static Methods diff --git a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmIntelTokenTagger.cs b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmIntelTokenTagger.cs index 9059c994..469b8d74 100644 --- a/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmIntelTokenTagger.cs +++ b/VS/CSHARP/asm-dude-vsix/SyntaxHighlighting/NasmIntelTokenTagger.cs @@ -174,8 +174,8 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } case AsmTokenType.UNKNOWN: // asmToken is not a known keyword, check if it is numerical { - if (AsmTools.AsmSourceTools.Parse_Constant(asmToken, true).Valid) - //if (AsmTools.AsmSourceTools.Evaluate_Constant(asmToken, true).Valid) + if (AsmSourceTools.Evaluate_Constant(asmToken, true).Valid) + //if (AsmSourceTools.Parse_Constant(asmToken, true).Valid) { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._constant); } @@ -246,7 +246,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti if (assember.HasFlag(AssemblerEnum.NASM_INTEL) || assember.HasFlag(AssemblerEnum.NASM_ATT)) { yield return new TagSpan(NasmIntelTokenTagger.New_Span(pos[k], offset, curSpan), this._directive); - } + } break; } case AsmTokenType.Mnemonic: @@ -267,7 +267,7 @@ public IEnumerable> GetTags(NormalizedSnapshotSpanCollecti } } } - AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmTokenTagger"); + AsmDudeToolsStatic.Print_Speed_Warning(time1, "NasmIntelTokenTagger"); } #region Public Static Methods