示例#1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        private void AddToplevel(
            string name
            )
        {
            ReturnCode         code;
            Result             result    = null;
            IObject            @object   = null;
            ToplevelDictionary toplevels = null;

            code = interpreter.GetObject(
                CollectionName, LookupFlags.Default,
                ref @object, ref result);

            if (code == ReturnCode.Ok)
            {
                toplevels = @object.Value as ToplevelDictionary;

                if (toplevels == null)
                {
                    toplevels     = new ToplevelDictionary();
                    @object.Value = toplevels;
                }

                toplevels.Add(name, new AnyPair <Thread, Toplevel>(
                                  Thread.CurrentThread, this));
            }
            else
            {
                toplevels = new ToplevelDictionary();

                toplevels.Add(name, new AnyPair <Thread, Toplevel>(
                                  Thread.CurrentThread, this));

                long token = 0;

                code = interpreter.AddObject(
                    CollectionName, null, ObjectFlags.Default,
                    ClientData.Empty, 0,
#if NATIVE && TCL
                    null,
#endif
#if DEBUGGER && DEBUGGER_ARGUMENTS
                    null,
#endif
                    toplevels, ref token, ref result);
            }

            if (code != ReturnCode.Ok)
            {
                throw new ScriptException(code, result);
            }
        }