예제 #1
0
        /// <summary>
        /// Searches the given symbol in the scope environment and
        /// sets the value if found.
        /// Throws an exception if the symbol is not found in the scope
        /// environment.
        /// </summary>
        /// <param name="symbolName">Name of the symbol.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="LispException">Symbol  + symbolName +  not found</exception>
        public void SetInScopes(string symbolName, object value)
        {
            LispScope foundClosureScope;
            object    val;

            if (!string.IsNullOrEmpty(symbolName))
            {
                if (ContainsKey(symbolName))
                {
                    this[symbolName] = value;
                }
                else if (IsInClosureChain(symbolName, out foundClosureScope, out val))
                {
                    foundClosureScope[symbolName] = value;
                }
                else if (GlobalScope != null && GlobalScope.ContainsKey(symbolName))
                {
                    GlobalScope[symbolName] = value;
                }
                else
                {
                    throw new LispException("Symbol " + symbolName + " not found", this);
                }
            }
        }
예제 #2
0
 public static Reference Identify(string Name)
 {
     for (LinkedListNode <Scope> node = scopeList.Last; node != null; node = node.Previous)
     {
         if (node.Value.ContainsKey(Name))
         {
             return(node.Value[Name]);
         }
         if (node.Value.Blocking)
         {
             break;
         }
     }
     if (GlobalScope.ContainsKey(Name))
     {
         return(GlobalScope[Name]);
     }
     return(NullReference.Value);
 }