Exemplo n.º 1
0
        /// <summary>
        /// Like <see cref="Find"/> but if the variable belongs to another strong scope than the current one, it is registered
        /// in the Closures of its strong scope.
        /// </summary>
        /// <param name="name">Name in the scope.</param>
        /// <returns>Null if not found.</returns>
        public AccessorLetExpr FindAndRegisterClosure(string name)
        {
            NameEntry t;

            if (_vars.TryGetValue(name, out t))
            {
                if (t.Next != null)
                {
                    t = t.Next;
                }
                if (t.Scope.StrongScope != _currentStrongScope)
                {
                    _currentStrongScope.AddClosure(t.E);
                }
                return(t.E);
            }
            return(null);
        }