Exemple #1
0
        // dumps all existing script block
        /// <exception cref="VariantException"></exception>
        public virtual void Dump(int width)
        {
            // dumps all existing script block
            string version = string.Format("TJS version %d.%d.%d", VERSION_MAJOR, VERSION_MINOR
                                           , VERSION_RELEASE);

            OutputToConsoleSeparator("#", width);
            OutputToConsoleWithCentering("TJS Context Dump", width);
            OutputToConsoleSeparator("#", width);
            OutputToConsole(version);
            OutputToConsole(string.Empty);
            // なくなっているオブジェクトを消す
            CompactScriptBlock();
            if (mScriptBlocks.Count > 0)
            {
                string buf = string.Format("Total %d script block(s)", mScriptBlocks.Count);
                OutputToConsole(buf);
                OutputToConsole(string.Empty);
                int totalcontexts = 0;
                int totalcodesize = 0;
                int totaldatasize = 0;
                foreach (WeakReference <ScriptBlock> scriptBlock in mScriptBlocks)
                {
                    ScriptBlock b = scriptBlock.Get();
                    if (b == null)
                    {
                        continue;
                    }
                    int    n;
                    string name = b.GetName();
                    string title;
                    if (name != null)
                    {
                        title = b.GetNameInfo();
                    }
                    else
                    {
                        title = "(no-named script block)";
                    }
                    string ptr = string.Format(" 0x%08X", b.GetHashCode());
                    title += ptr;
                    OutputToConsole(title);
                    n              = b.GetContextCount();
                    totalcontexts += n;
                    buf            = string.Format("\tCount of contexts      : %d", n);
                    OutputToConsole(buf);
                    n              = b.GetTotalVMCodeSize();
                    totalcodesize += n;
                    buf            = string.Format("\tVM code area size      : %d words", n);
                    OutputToConsole(buf);
                    n              = b.GetTotalVMDataSize();
                    totaldatasize += n;
                    buf            = string.Format("\tVM constant data count : %d", n);
                    OutputToConsole(buf);
                    OutputToConsole(string.Empty);
                }
                buf = string.Format("Total count of contexts      : %d", totalcontexts);
                OutputToConsole(buf);
                buf = string.Format("Total VM code area size      : %d words", totalcodesize);
                OutputToConsole(buf);
                buf = string.Format("Total VM constant data count : %d", totaldatasize);
                OutputToConsole(buf);
                OutputToConsole(string.Empty);
                for (int i_1 = 0; i_1 < mScriptBlocks.Count; i_1++)
                {
                    ScriptBlock b = mScriptBlocks[i_1].Get();
                    if (b == null)
                    {
                        continue;
                    }
                    OutputToConsoleSeparator("-", width);
                    string name = b.GetName();
                    string title;
                    if (name != null)
                    {
                        title = b.GetNameInfo();
                    }
                    else
                    {
                        title = "(no-named script block)";
                    }
                    string ptr;
                    ptr    = string.Format(" 0x%08X", b.GetHashCode());
                    title += ptr;
                    OutputToConsoleWithCentering(title, width);
                    OutputToConsoleSeparator("-", width);
                    b.Dump();
                    OutputToConsole(string.Empty);
                    OutputToConsole(string.Empty);
                }
            }
            else
            {
                OutputToConsole(string.Empty);
                OutputToConsole("There are no script blocks in the system.");
            }
        }