private void Simulate(int lineNumber) { if (!this.Is_Enabled) { return; } #region Payload lock (this._updateLock) { DateTime time1 = DateTime.Now; this._busy = true; this._scheduled.Remove(lineNumber); IState_R result = this._runner.ExecuteTree_Backward(this._cflow, lineNumber, 6); this._cachedStates.Remove(lineNumber); this._cachedStates.Add(lineNumber, result); this._busy = false; On_Simulate_Done_Event(new CustomEventArgs("Simulate has finished")); AsmDudeToolsStatic.Print_Speed_Warning(time1, "AsmSimulator"); } #endregion Payload if (this._scheduled.Count > 0) { int lineNumber2; lock (this._updateLock) { lineNumber2 = this._scheduled.GetEnumerator().Current; this._scheduled.Remove(lineNumber2); } this.Simulate(lineNumber2); } }
public string GetRegisterValue(Rn name, IState_R state) { if (state == null) { return(""); } Tv5[] reg = state.GetTv5Array(name); return(string.Format("{0} = {1}", ToolsZ3.ToStringBin(reg), ToolsZ3.ToStringHex(reg))); }
public void UpdateState(int lineNumber) { if (!(this._cachedStates.ContainsKey(lineNumber))) { IState_R result = this._runner.ExecuteTree_Backward(this._cflow, lineNumber, 6); this._cachedStates.Add(lineNumber, result); On_Simulate_Done_Event(new CustomEventArgs("Simulate has finished")); } }
public IEnumerable <ITagSpan <ErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (spans.Count == 0) { // there is no content in the buffer yield break; } DateTime time1 = DateTime.Now; if (this._asmSimulator.Is_Enabled) { foreach (IMappingTagSpan <AsmTokenTag> asmTokenTag in this._aggregator.GetTags(spans)) { SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer)[0]; switch (asmTokenTag.Tag.Type) { case AsmTokenType.Register: { int lineNumber = Get_Linenumber(tagSpan); string regNameStr = tagSpan.GetText(); Rn regName = RegisterTools.ParseRn(regNameStr); //AsmSimToolsStatic.Output_INFO(string.Format("AsmSimSquigglesTagger:GetTags: found register " + regName + " at line " + lineNumber)); IState_R state = this._asmSimulator.GetState(lineNumber, false); if (state != null) { // only show squiggles to indicate that information is available yield return(new TagSpan <ErrorTag>(tagSpan, new ErrorTag("infomation"))); } else { //AsmDudeToolsStatic.Output_INFO("InfoSquigglesTagger:GetTags: found register " + regName + " at line " + lineNumber +" but state was null"); } break; } } } } AsmDudeToolsStatic.Print_Speed_Warning(time1, "InfoSquigglesTagger"); }
/// <summary> /// Determine which pieces of Quickinfo content should be displayed /// </summary> public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession"); applicableToSpan = null; try { DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } string keyword = ""; IEnumerable <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: enumerator.Count="+ enumerator.Count()); if (enumerator.Count() > 0) { if (false) { // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (enumerator.Count() > 1) { foreach (IMappingTagSpan <AsmTokenTag> v in enumerator) { AsmDudeToolsStatic.Output(string.Format("WARNING: {0}:AugmentQuickInfoSession. more than one tag! \"{1}\"", ToString(), v.Span.GetSpans(this._sourceBuffer).First().GetText())); } } } IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.First(); SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer).First(); keyword = tagSpan.GetText(); int lineNumber = tagSpan.Snapshot.GetLineNumberFromPosition(tagSpan.Start); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); string keywordUpper = keyword.ToUpper(); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive); TextBlock description = null; switch (asmTokenTag.Tag.Type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Register: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Register ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register)))); string register_Descr = this._asmDudeTools.Get_Description(keywordUpper); if (register_Descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + register_Descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } if (this._asmSimulator.Is_Enabled) { IState_R state = this._asmSimulator.GetState(lineNumber, true); string msg = this._asmSimulator.GetRegisterValue(RegisterTools.ParseRn(keyword), state); if (msg.Length == 0) { msg = "Calculating register content"; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap("\n" + msg, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Mnemonic ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Opcode)))); Mnemonic mmemonic = AsmSourceTools.ParseMnemonic(keywordUpper); { string archStr = ":" + ArchTools.ToString(this._asmDudeTools.Mnemonic_Store.GetArch(mmemonic)) + " "; string descr = this._asmDudeTools.Mnemonic_Store.GetDescription(mmemonic); description.Inlines.Add(new Run(AsmSourceTools.Linewrap(archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } { // show performance information MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On(); IReadOnlyList <PerformanceItem> performanceData = this._asmDudeTools.Performance_Store.GetPerformance(mmemonic, selectedMicroarchitures); if (performanceData.Count > 0) { FontFamily family = new FontFamily("Consolas"); IList <Run> list = new List <Run>(); description.Inlines.Add(new Run(string.Format("\n\n{0,-15}{1,-24}{2,-10}{3,-10}\n", "Architecture", "Instruction", "Latency", "Throughput")) { FontFamily = family, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold, Foreground = this._foreground }); foreach (PerformanceItem item in performanceData) { description.Inlines.Add(new Run(string.Format("{0,-15}{1,-24}{2,-10}{3,-10}{4,-10}\n", item._microArch, item._instr + " " + item._args, item._latency, item._throughput, item._remark)) { FontFamily = family, Foreground = this._foreground }); } } } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); } catch (Exception e) { AsmDudeToolsStatic.Output(string.Format("ERROR: {0}:AugmentQuickInfoSession; e={1}", ToString(), e.ToString())); } }