예제 #1
0
파일: Symbol.cs 프로젝트: nguerrera/scheme
        public static Symbol For(string value)
        {
            Symbol result;
            if (Symbol.table.TryGetValue(value, out result))
                return result;

            result = new Symbol(value);
            Symbol.table.Add(value, result);
            return result;
        }
예제 #2
0
 public SchemeObject GetValue(Symbol key)
 {
     for (SchemeEnvironment env = this; env != null; env = env.parent)
     {
         SchemeObject value;
         if (env.dictionary.TryGetValue(key, out value))
             return value;
     }
     throw new InvalidSyntaxException();
 }
예제 #3
0
        public void SetValue(Symbol key, SchemeObject value, bool isDefinition)
        {
            SchemeEnvironment env = this;
            if (!isDefinition)
            {
                for (; env != null; env = env.parent)
                    if (env.dictionary.ContainsKey(key))
                        break;

                if (env == null)
                    throw new InvalidSyntaxException();
            }
            env.dictionary[key] = value;
        }
예제 #4
0
 public void Add(Symbol key, SchemeObject value)
 {
     this.dictionary[key] = value;
 }
예제 #5
0
 internal AssignmentContinuation(Symbol destination, bool isDefinition, SchemeEnvironment environment)
     : base(environment, ContinuationKind.Assignment)
 {
     this.Destination = destination;
     this.IsDefinition = isDefinition;
 }