コード例 #1
0
ファイル: Disassembler.cs プロジェクト: hgomez/C64Studio
        private void btnExportAssembly_Click(object sender, EventArgs e)
        {
            string disassembly;

            if (!m_Disassembler.Disassemble(m_DisassemblyProject.DataStartAddress, m_DisassemblyProject.JumpedAtAddresses, m_DisassemblyProject.NamedLabels, false, out disassembly))
            {
                return;
            }

            string newFilename = "disassembly.asm";

            try
            {
                newFilename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(m_OpenedFilename), System.IO.Path.GetFileNameWithoutExtension(m_OpenedFilename)) + ".asm";
            }
            catch (Exception)
            {
                newFilename = "disassembly.asm";
            }

            if (Core.MainForm.m_Solution != null)
            {
                while (Core.MainForm.m_Solution.FilenameUsed(newFilename))
                {
                    newFilename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(m_OpenedFilename), System.IO.Path.GetFileNameWithoutExtension(m_OpenedFilename)) + "1.asm";
                }
            }
            SourceASMEx document = new SourceASMEx(Core);

            document.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Document;
            document.Core     = Core;
            document.Text     = System.IO.Path.GetFileName(newFilename);
            document.FillContent(disassembly);
            document.Show(Core.MainForm.panelMain);
        }
コード例 #2
0
ファイル: DocumentInfo.cs プロジェクト: jeason0813/C64Studio
        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;
            }
        }
コード例 #3
0
ファイル: CompileResult.cs プロジェクト: jeason0813/C64Studio
        public void UpdateFromMessages(Parser.ParserBase Parser, Project ParsedProject)
        {
            if (InvokeRequired)
            {
                Invoke(new UpdateFromMessagesCallback(UpdateFromMessages), new object[] { Parser, ParsedProject });
                return;
            }

            m_ListProject = ParsedProject;
            ClearMessages();

            listMessages.BeginUpdate();
            SortOrder oldOrder = listMessages.Sorting;

            listMessages.Sorting            = SortOrder.None;
            listMessages.ListViewItemSorter = null;

            foreach (var docInfos in Core.MainForm.DocumentInfos)
            {
                if ((docInfos.Type == ProjectElement.ElementType.ASM_SOURCE) &&
                    (docInfos.BaseDoc != null))
                {
                    SourceASMEx source = (SourceASMEx)docInfos.BaseDoc;

                    source.RemoveAllErrorMarkings();
                }
            }
            foreach (System.Collections.Generic.KeyValuePair <int, Parser.ParserBase.ParseMessage> msg in Parser.Messages)
            {
                int lineIndex = msg.Key;
                Parser.ParserBase.ParseMessage message = msg.Value;

                /*
                 * if ( message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.MESSAGE )
                 * {
                 * continue;
                 * }*/
                if (Core.Settings.IgnoredWarnings.ContainsValue(message.Code))
                {
                    // ignore warning
                    continue;
                }

                string documentFile = "";
                int    documentLine = -1;
                //Debug.Log( "a" );
                Parser.DocumentAndLineFromGlobalLine(lineIndex, out documentFile, out documentLine);
                //Debug.Log( "b" );
                if (message.AlternativeFile == null)
                {
                    message.AlternativeFile      = documentFile;
                    message.AlternativeLineIndex = documentLine;
                }

                if (message.CharIndex != -1)
                {
                    if (ParsedProject == null)
                    {
                        var sourceDocInfo = Core.MainForm.DetermineDocumentByFileName(documentFile);
                        if ((sourceDocInfo != null) &&
                            (sourceDocInfo.BaseDoc != null) &&
                            (sourceDocInfo.Type == ProjectElement.ElementType.ASM_SOURCE))
                        {
                            var sourceFile = (SourceASMEx)sourceDocInfo.BaseDoc;
                            if (sourceFile != null)
                            {
                                sourceFile.MarkTextAsError(documentLine, message.CharIndex, message.Length);
                            }
                        }
                    }
                    else
                    {
                        var sourceElement = ParsedProject.GetElementByFilename(documentFile);
                        if (sourceElement != null)
                        {
                            var sourceFile = (SourceASMEx)sourceElement.Document;
                            if (sourceFile != null)
                            {
                                sourceFile.MarkTextAsError(documentLine, message.CharIndex, message.Length);
                            }
                            else
                            {
                                // TODO - have no document to mark?
                            }
                        }
                        else
                        {
                            // TODO - have no document to mark?
                        }
                    }
                }

                //dh.Log( "Error in " + lineIndex );

                ++documentLine;

                ListViewItem item = new ListViewItem();

                if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR)
                {
                    item.ImageIndex = 0;
                    item.Text       = "0";
                }
                else if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING)
                {
                    item.ImageIndex = 1;
                    item.Text       = "2";
                }
                else if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING)
                {
                    item.ImageIndex = 2;
                    item.Text       = "1";
                }
                else
                {
                    item.Text = "3";
                }
                item.SubItems.Add(documentLine.ToString());

                string messageCode = message.Code.ToString();
                if (messageCode.Length >= 5)
                {
                    item.SubItems.Add(messageCode.Substring(0, 5));
                }
                else
                {
                    item.SubItems.Add(messageCode);
                }
                if (documentFile != null)
                {
                    item.SubItems.Add(documentFile.ToString());
                }
                else
                {
                    item.SubItems.Add("--");
                }
                item.SubItems.Add(message.Message);
                item.Tag = message;

                //Debug.Log( "c" );
                listMessages.Items.Add(item);
                //Debug.Log( "d" );
                if (message.ChildMessages != null)
                {
                    foreach (var childMessage in message.ChildMessages)
                    {
                        ListViewItem childItem = new ListViewItem();

                        if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR)
                        {
                            childItem.ImageIndex = 0;
                            childItem.Text       = "0";
                        }
                        else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING)
                        {
                            childItem.ImageIndex = 1;
                            childItem.Text       = "2";
                        }
                        else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING)
                        {
                            childItem.ImageIndex = 2;
                            childItem.Text       = "1";
                        }
                        else
                        {
                            childItem.Text = "3";
                        }
                        childItem.SubItems.Add(documentLine.ToString());
                        childItem.SubItems.Add(childMessage.Code.ToString().Substring(0, 5));
                        childItem.SubItems.Add(documentFile.ToString());
                        childItem.SubItems.Add(childMessage.Message);
                        childItem.Tag = childMessage;

                        //Debug.Log( "c" );
                        listMessages.Items.Add(childItem);
                    }
                }
            }
            //Debug.Log( "e" );
            listMessages.Sorting            = oldOrder;
            listMessages.ListViewItemSorter = new CompileResultItemComparer(listMessagesSortColumn, listMessages.Sorting);
            //listMessages.Sort();
            //Debug.Log( "f" );
            listMessages.EndUpdate();
        }