public void SetASMFileInfo(Types.ASM.FileInfo FileInfo, List <Types.AutoCompleteItemInfo> KnownTokenList, GR.Collections.MultiMap <string, Types.SymbolInfo> KnownTokenInfo) { SourceASMEx asm = null; if ((BaseDoc != null) && (Type == ProjectElement.ElementType.ASM_SOURCE)) { asm = BaseDoc as SourceASMEx; } if (asm != null) { asm.DoNotFollowZoneSelectors = true; asm.SetLineInfos(FileInfo); } ASMFileInfo = FileInfo; KnownKeywords = KnownTokenList; KnownTokens = KnownTokenInfo; if (BaseDoc != null) { BaseDoc.Core.MainForm.AddTask(new Tasks.TaskUpdateKeywords(BaseDoc)); } if (Element != null) { // and to all it's deduced dependencies! foreach (var dependencyBuildState in DeducedDependency.Values) { foreach (var dependency in dependencyBuildState.BuildState.Keys) { ProjectElement element = Project.GetElementByFilename(dependency); if ((element != null) && (element.DocumentInfo.Type == ProjectElement.ElementType.ASM_SOURCE)) { element.DocumentInfo.SetASMFileInfo(FileInfo, KnownTokenList, KnownTokenInfo); } } } } if (asm != null) { asm.DoNotFollowZoneSelectors = false; } }
private void RefreshNodes() { treeProject.BeginUpdate(); NodeRoot.Nodes.Clear(); IList <Types.SymbolInfo> sortedTokens = null; // sort by line number if (Core.Settings.OutlineSortByIndex) { GR.Collections.MultiMap <int, Types.SymbolInfo> sortedTokensInner = new GR.Collections.MultiMap <int, C64Studio.Types.SymbolInfo>(); foreach (KeyValuePair <string, Types.SymbolInfo> token in OutlineTokens) { if (!string.IsNullOrEmpty(Core.Settings.OutlineFilter)) { if (token.Key.ToUpper().Contains(Core.Settings.OutlineFilter.ToUpper())) { sortedTokensInner.Add(token.Value.LineIndex, token.Value); } } else { sortedTokensInner.Add(token.Value.LineIndex, token.Value); } } sortedTokens = sortedTokensInner.Values; } else { GR.Collections.MultiMap <string, Types.SymbolInfo> sortedTokensInner = new GR.Collections.MultiMap <string, C64Studio.Types.SymbolInfo>(); foreach (KeyValuePair <string, Types.SymbolInfo> token in OutlineTokens) { if (!string.IsNullOrEmpty(Core.Settings.OutlineFilter)) { if (token.Key.ToUpper().Contains(Core.Settings.OutlineFilter.ToUpper())) { sortedTokensInner.Add(token.Key.ToUpper(), token.Value); } } else { sortedTokensInner.Add(token.Key.ToUpper(), token.Value); } } sortedTokens = sortedTokensInner.Values; } string curZone = ""; System.Windows.Forms.TreeNode parentNode = new System.Windows.Forms.TreeNode(); parentNode = new System.Windows.Forms.TreeNode(); parentNode.Text = "Global Zone"; parentNode.ImageIndex = parentNode.SelectedImageIndex = 0; NodeRoot.Nodes.Add(parentNode); System.Windows.Forms.TreeNode globalZone = parentNode; Dictionary <string, TreeNode> zoneNodes = new Dictionary <string, TreeNode>(); zoneNodes.Add(parentNode.Text, globalZone); // add zone nodes first foreach (var token in sortedTokens) { if (token.Type == C64Studio.Types.SymbolInfo.Types.ZONE) { System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode(); node.Text = token.Name; node.Tag = token; parentNode = new System.Windows.Forms.TreeNode(); parentNode.Text = token.Zone; parentNode.ImageIndex = parentNode.SelectedImageIndex = 0; NodeRoot.Nodes.Add(parentNode); parentNode.Tag = token; zoneNodes.Add(parentNode.Text, parentNode); } } // now add child nodes parentNode = globalZone; foreach (var token in sortedTokens) { if (token.Type == C64Studio.Types.SymbolInfo.Types.ZONE) { curZone = token.Zone; parentNode = zoneNodes[token.Zone]; continue; } System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode(); bool addNode = true; node.Text = token.Name; node.Tag = token; switch (token.Type) { case C64Studio.Types.SymbolInfo.Types.CONSTANT_1: case C64Studio.Types.SymbolInfo.Types.CONSTANT_2: node.ImageIndex = node.SelectedImageIndex = 2; node.Text += " = $" + token.AddressOrValue.ToString("X4"); break; case C64Studio.Types.SymbolInfo.Types.LABEL: if ((token.Name.Contains(".")) && (!Core.Settings.OutlineShowLocalLabels)) { addNode = false; } if ((token.Name.StartsWith(C64Studio.Parser.ASMFileParser.InternalLabelPrefix)) && (!Core.Settings.OutlineShowShortCutLabels)) { addNode = false; } node.ImageIndex = node.SelectedImageIndex = 1; node.Text += " = $" + token.AddressOrValue.ToString("X4"); break; case C64Studio.Types.SymbolInfo.Types.PREPROCESSOR_LABEL: case C64Studio.Types.SymbolInfo.Types.PREPROCESSOR_CONSTANT_1: case C64Studio.Types.SymbolInfo.Types.PREPROCESSOR_CONSTANT_2: node.ImageIndex = node.SelectedImageIndex = 3; node.Text += " = $" + token.AddressOrValue.ToString("X4"); break; case C64Studio.Types.SymbolInfo.Types.UNKNOWN: break; } if (!addNode) { continue; } // cut off zone try { // find parent node if ((string.IsNullOrEmpty(token.Zone)) || (!zoneNodes.ContainsKey(token.Zone))) { globalZone.Nodes.Add(node); } else //if ( curZone.Length > 0 ) { var parentZoneNode = zoneNodes[token.Zone]; int dotPos = node.Text.IndexOf('.'); string nodeParentText = parentZoneNode.Text; if (dotPos != -1) { node.Text = node.Text.Substring(dotPos); } parentZoneNode.Nodes.Add(node); if ((_ExpandedNodes.ContainsKey(nodeParentText)) && (_ExpandedNodes[nodeParentText])) { parentZoneNode.Expand(); } } } catch (Exception ex) { Debug.Log(ex.Message); } } NodeRoot.Expand(); treeProject.EndUpdate(); }
protected override bool ProcessTask() { if ((m_Document.Type != ProjectElement.ElementType.ASM_SOURCE) && (m_Document.Type != ProjectElement.ElementType.BASIC_SOURCE)) { return(true); } if (m_Document.Type == ProjectElement.ElementType.ASM_SOURCE) { Parser.ASMFileParser parser = new Parser.ASMFileParser(); var compileConfig = new RetroDevStudio.Parser.CompileConfig(); if (m_Document.Element != null) { compileConfig.Assembler = m_Document.Element.AssemblerType; } string sourceCode = ""; if (m_Document.BaseDoc != null) { sourceCode = ((SourceASMEx)m_Document.BaseDoc).editSource.Text; } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig, null); if ((compileConfig.Assembler != RetroDevStudio.Types.AssemblerType.AUTO) && (m_Document.BaseDoc != null) && (m_Document.Element != null)) { if (m_Document.Element.AssemblerType != compileConfig.Assembler) { m_Document.Element.AssemblerType = compileConfig.Assembler; m_Document.BaseDoc.SetModified(); } } if (m_Document.BaseDoc != null) { ((SourceASMEx)m_Document.BaseDoc).SetLineInfos(parser.ASMFileInfo); } var knownTokens = parser.KnownTokens(); GR.Collections.MultiMap <string, SymbolInfo> knownTokenInfos = parser.KnownTokenInfo(); m_Document.SetASMFileInfo(parser.ASMFileInfo, knownTokens, knownTokenInfos); } else if (m_Document.Type == ProjectElement.ElementType.BASIC_SOURCE) { Parser.ParserBase parser = Core.DetermineParser(m_Document); ((Parser.BasicFileParser)parser).SetBasicDialect(((Parser.BasicFileParser)parser).Settings.BASICDialect); if (m_Document.BaseDoc != null) { ((Parser.BasicFileParser)parser).Settings.UpperCaseMode = !((SourceBasicEx)m_Document.BaseDoc).m_LowerCaseMode; } var compileConfig = new RetroDevStudio.Parser.CompileConfig(); if (m_Document.Element != null) { compileConfig.Assembler = m_Document.Element.AssemblerType; } string sourceCode = ""; if (m_Document.BaseDoc != null) { sourceCode = ((SourceBasicEx)m_Document.BaseDoc).editSource.Text; } parser.ParseFile(m_Document.FullPath, sourceCode, m_Configuration, compileConfig, null); } var task = new Tasks.TaskUpdateKeywords(m_Document.BaseDoc); task.Core = Core; task.RunTask(); return(true); }