コード例 #1
0
        /// <summary>
        /// Generates the initial mGlobalFlags and mGlobalLabels lists, as well as the
        /// full cross-reference pair list.
        /// </summary>
        private void GenerateLists()
        {
            // For every offset that has a label, add an entry to the source/target pair list
            // for every offset that references it.
            //
            // If the label isn't marked as "local or global", add it to the global-label list.
            //
            // The first label encountered is always treated as global.  Note it may not appear
            // at offset zero.

            bool first = true;

            for (int offset = 0; offset < mProject.FileDataLength; offset++)
            {
                // Find all user labels and auto labels.
                Symbol sym = mProject.GetAnattrib(offset).Symbol;

                // In cc65, variable declarations end the local label scope.  We insert a
                // fake global symbol if we encounter a table with a nonzero number of entries.
                if (QuirkVariablesEndScope &&
                    mProject.LvTables.TryGetValue(offset, out LocalVariableTable value) &&
                    value.Count > 0)
                {
                    mGlobalFlags[offset] = true;
                    mGlobalLabels.Add(new OffsetLabel(offset, "!VARTAB!"));
                    continue;
                }
                if (sym == null)
                {
                    // No label at this offset.
                    continue;
                }

                if (first || !sym.CanBeLocal)
                {
                    first = false;
                    mGlobalFlags[offset] = true;
                    mGlobalLabels.Add(new OffsetLabel(offset, sym.Label));

                    // Don't add to pairs list.
                    continue;
                }

                // If nothing actually references this label, the xref set will be empty.
                XrefSet xrefs = mProject.GetXrefSet(offset);
                if (xrefs != null)
                {
                    foreach (XrefSet.Xref xref in xrefs)
                    {
                        if (!xref.IsByName)
                        {
                            continue;
                        }

                        mOffsetPairs.Add(new OffsetPair(xref.Offset, offset));
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Generates the initial mGlobalFlags and mGlobalLabels lists, as well as the
        /// full cross-reference pair list.
        /// </summary>
        private void GenerateLists()
        {
            // For every offset that has a label, add an entry to the source/target pair list
            // for every offset that references it.
            //
            // If the label isn't marked as "local or global", add it to the global-label list.
            //
            // The first label encountered is always treated as global.  Note it may not appear
            // at offset zero.

            bool first = true;

            for (int i = 0; i < mProject.FileDataLength; i++)
            {
                Symbol sym = mProject.GetAnattrib(i).Symbol;
                if (sym == null)
                {
                    // No label at this offset.
                    continue;
                }

                if (first || sym.SymbolType != Symbol.Type.LocalOrGlobalAddr)
                {
                    first           = false;
                    mGlobalFlags[i] = true;
                    mGlobalLabels.Add(new OffsetLabel(i, sym.Label));

                    // Don't add to pairs list.
                    continue;
                }

                // If nothing actually references this label, the xref set will be empty.
                XrefSet xrefs = mProject.GetXrefSet(i);
                if (xrefs != null)
                {
                    foreach (XrefSet.Xref xref in xrefs)
                    {
                        if (!xref.IsSymbolic)
                        {
                            continue;
                        }

                        mOffsetPairs.Add(new OffsetPair(xref.Offset, i));
                    }
                }
            }
        }