Пример #1
0
 public object Setq(Symbol id, object value)
 {
     ILocation<object> binding;
     if (!variables.TryGetValue (id, out binding))
         Bind (id, Namespace.Variable, new ValueCell<object> (value));
     else
         binding.Value = value;
     return value;
 }
Пример #2
0
 public void Bind(Symbol id, Namespace nspace, ILocation<Object> location)
 {
     switch (nspace)
     {
         case Namespace.Variable:
             variables.Add(id, location);
             break;
         default:
             throw new NotImplementedException ();
     }
 }
Пример #3
0
 public Delegate SymbolFunction(Symbol id)
 {
     ILocation<Delegate> binding;
     if (functions.TryGetValue (id, out binding))
         return binding.Value;
     if (id.NamesDotnetMethod ()) {
         Delegate gf = (Delegate) CL.EnsureGenericFunction (id, KW.GenericFunctionClass, CLOS.DotnetGenericFunction,
                                                                KW.Environment, this,
                                                                KW.StudlyName, id.Name);
         binding = new ValueCell<Delegate> (gf);
         return binding.Value;
     }
     else
         throw new NotImplementedException ();
 }
Пример #4
0
 public object SymbolValue(Symbol id)
 {
     ILocation<object> binding;
     if (variables.TryGetValue (id, out binding))
         return binding.Value;
     else
         throw new NotImplementedException ();
 }
Пример #5
0
 public bool IsFbound(Symbol id)
 {
     return functions.ContainsKey (id);
 }
Пример #6
0
 public bool IsBound(Symbol id)
 {
     return variables.ContainsKey (id);
 }
Пример #7
0
 public virtual Symbol Intern(string name)
 {
     if (name == null)
         throw new ArgumentNullException ("name");
     Predicate<Symbol> matchString = new Predicate<Symbol> (new StringMatcher (name).MatchesSymbol);
     Symbol probe = this.PresentSymbolList.Find (matchString);
     if (probe != null)
         return probe;
     else {
         foreach (Package u in this.PackageUseList) {
             probe = u.ExternalSymbolList.Find (matchString);
             if (probe != null)
                 return probe;
         }
         probe = new Symbol (name, this);
         this.PresentSymbolList.Add (probe);
         return probe;
     }
 }
Пример #8
0
 public void Export(Symbol sym)
 {
     if (this.ExternalSymbolList.Contains (sym))
         return;
     this.ExternalSymbolList.Add (sym);
 }
Пример #9
0
 public bool MatchesSymbol(Symbol s)
 {
     return s.Name == this.ToMatch;
 }