Exemple #1
0
        private static void _Kill(Script tokill)
        {
            if (tokill.m_isAlive)
            {
                if (tokill.OnScriptKilled != null)
                {
                    tokill.OnScriptKilled(tokill);
                }
                tokill.m_MainProcessor = null;
                tokill.m_ByteCode      = null;
                tokill.m_Sources       = null;

                for (int i = 0; i != tokill._childClosures.Count; i++)
                {
                    WeakReference wr = tokill._childClosures[i];
                    if (wr.IsAlive)
                    {
                        Closure c = (Closure)wr.Target;
                        Closure.Kill(ref c);
                    }
                }
                tokill._childClosures.Clear();
                tokill._childClosures = null;

                for (int i = 0; i != tokill._childTables.Count; i++)
                {
                    WeakReference wr = tokill._childTables[i];
                    if (wr.IsAlive)
                    {
                        Table t = (Table)wr.Target;
                        Table.Kill(ref t);
                    }
                }
                tokill._childTables.Clear();
                tokill._childTables = null;
                Table.Kill(ref tokill.m_GlobalTable);

                tokill.m_Debugger = null;

                if (tokill.m_TypeMetatables != null)
                {
                    for (int i = 0; i != tokill.m_TypeMetatables.Length; i++)
                    {
                        Table.Kill(ref tokill.m_TypeMetatables[i]);
                    }
                }
                tokill.m_TypeMetatables = null;

                tokill.m_isAlive = false;
            }
        }