예제 #1
0
        private bool TryGetLocal(string name, out object ret)
        {
            // couple of exception-free fast paths...
            IDictionary <object, object> dict = f_locals as IDictionary <object, object>;

            if (dict != null)
            {
                if (dict.TryGetValue(name, out ret))
                {
                    return(true);
                }
            }

            IMapping imap = f_locals as IMapping;

            if (imap != null)
            {
                return(imap.TryGetValue(name, out ret));
            }

            // uh-oh, we may end up throwing...
            try {
                ret = Ops.GetIndex(f_locals, name);
                return(true);
            } catch (KeyNotFoundException) {
                // return false
            }
            ret = null;
            return(false);
        }