public ScriptInterpreter FindOrCreate(object key, ScriptInterpreter parent)
 {
     if (parent != null) return parent.newInterpreter(key);
     lock (interpsForObjects)
     {
         ScriptInterpreter mini;
         if (!interpsForObjects.TryGetValue(key, out mini))
         {
             mini = newInterpreter(key);
             interpsForObjects[key] = mini;
         }
         return mini;
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="source"></param>
        /// <param name="extendEnv"></param>
        /// <param name="scopeOrCurrentResolver"></param>
        /// <param name="reusableIdentityOrSelf"></param>
        /// <param name="parentCtx"></param>
        /// <returns></returns>
        public static object EvalFromReader(string lang, TextReader source, bool extendEnv,
                                            ICollectionProvider scopeOrCurrentResolver, object reusableIdentityOrSelf, ScriptInterpreter parentCtx)
        {
            if (parentCtx == null)
            {
                parentCtx = FindOrCreate(lang, reusableIdentityOrSelf, null);
            }
            var si = parentCtx.newInterpreter(reusableIdentityOrSelf);

            if (extendEnv)
            {
                si = si.newInterpreter(scopeOrCurrentResolver);
            }
            return(si.Eval(source));
        }
Exemple #3
0
 public ScriptInterpreter FindOrCreate(object key, ScriptInterpreter parent)
 {
     if (parent != null)
     {
         return(parent.newInterpreter(key));
     }
     lock (interpsForObjects)
     {
         ScriptInterpreter mini;
         if (!interpsForObjects.TryGetValue(key, out mini))
         {
             mini = newInterpreter(key);
             interpsForObjects[key] = mini;
         }
         return(mini);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ScriptInterpreter LoadScriptInterpreter0(string type, object self, ScriptInterpreter parent)
        {
            var Interpreters = ScriptManager.Interpreters;

            lock (Interpreters)
            {
                var ret = UsedCSharpScriptDefinedType(self, type);
                if (ret != null)
                {
                    return(ret);
                }
                ScriptInterpreter typed = null;
                foreach (ScriptInterpreter set in Interpreters)
                {
                    if (set.LoadsFileType(type))
                    {
                        typed = set;
                        if (self != null)
                        {
                            if (typed.IsSelf(self))
                            {
                                return(set);
                            }
                        }
                    }
                }
                if (typed != null)
                {
                    return(typed.newInterpreter(self));
                }
                ScanPredfinedAssemblies();
                InstanceNewInterpTypes(self);
                return(FindOrCreate(type, self, parent));

                //default
                var dl = new DotLispInterpreter();
                dl.Self = self;
                return(dl);
            } // method: LoadScriptInterpreter
        }
        public static ScriptInterpreter FindOrCreate(string type, object self, ScriptInterpreter parent)
        {
            ScriptInterpreterFactory maker;

            if (parent == null)
            {
                maker = GetInterpreterFactory(type);
            }
            else
            {
                maker = parent.GetLoaderOfFiletype(type) ?? GetInterpreterFactory(type);
            }
            if (maker == null)
            {
                return(null);
            }
            ScriptInterpreter si = maker.GetLoaderOfFiletype(type);

            if (si == null)
            {
                return(null);
            }
            return(si.newInterpreter(self));
        }