Ejemplo n.º 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;
 }
Ejemplo n.º 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 ();
     }
 }
Ejemplo n.º 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 ();
 }
Ejemplo n.º 4
0
 public object SymbolValue(Symbol id)
 {
     ILocation<object> binding;
     if (variables.TryGetValue (id, out binding))
         return binding.Value;
     else
         throw new NotImplementedException ();
 }
Ejemplo n.º 5
0
 public bool IsFbound(Symbol id)
 {
     return functions.ContainsKey (id);
 }
Ejemplo n.º 6
0
 public bool IsBound(Symbol id)
 {
     return variables.ContainsKey (id);
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 8
0
 public void Export(Symbol sym)
 {
     if (this.ExternalSymbolList.Contains (sym))
         return;
     this.ExternalSymbolList.Add (sym);
 }
Ejemplo n.º 9
0
 public bool MatchesSymbol(Symbol s)
 {
     return s.Name == this.ToMatch;
 }