2 using System.Collections.Generic;
7 public sealed class MSymbol
9 private static Dictionary<string, MSymbol> pool
10 = new Dictionary<string, MSymbol> ();
12 public readonly string Name;
14 internal MProperty.Flags? flags;
16 public static MSymbol nil = MSymbol.Of ("nil");
17 public static MSymbol t = MSymbol.Of ("t");
18 public static MSymbol symbol = MSymbol.Of ("symbol");
19 public static MSymbol mtext = MSymbol.Of ("mtext");
20 public static MSymbol plist = MSymbol.Of ("plist");
21 public static MSymbol integer = MSymbol.Of ("integer");
23 private MSymbol (string name)
28 public static MSymbol Of (string name)
34 if (! pool.TryGetValue (name, out sym))
36 sym = new MSymbol (name);
43 public static MSymbol PropertyKey (string name)
45 MSymbol sym = MSymbol.Of (name);
47 if (sym.flags == null)
48 sym.flags = MProperty.Flags.None;;
52 public static MSymbol PropertyKey (string name, MProperty.Flags flags)
54 MSymbol sym = MSymbol.Of (name);
56 if (sym.flags == null)
58 else if (sym.flags != flags)
59 throw new Exception ("Flags of PropertyKey mismatch");
63 public override string ToString ()
67 foreach (char c in Name)
69 if (c == '\\' || c == ' ' || c == '\'' || c == '\"' || c == ':')
76 public MPlist Find (MSymbol key)
78 return (Plist == null ? null : Plist.Find (key));
81 public object Get (MSymbol key)
83 return (Plist == null ? null : Plist.Get (key));
86 public object Put (MSymbol key, object val)
89 Plist = new MPlist ();
90 return Plist.Put (key, val);