private void MakeTree() { // TODO: Rework this to use small structs instead of actual Atoms. log.Info("Generating Tree..."); this.Tree = new Atom("/"); using (TextWriter f = File.CreateText("objtree.txt")) { List <string> keys = this.Atoms.Keys.ToList(); keys.Sort(); foreach (string key in keys) { f.WriteLine(key); Atom atom = this.Atoms[key]; cpath.Clear(); Atom cNode = this.Tree; BYONDType fullpath = atom.Type;//this.SplitPath(atom.Type.ToString()).ToList(); string[] truncatedPath = fullpath.GetPathSegments(); foreach (string path_item in truncatedPath) { cpath.Add(path_item); string cpath_str = "/" + ("/".join(cpath)); // if path_item == "var": // if path_item not in cNode.properties: // cNode.properties[fullpath[-1]]="???" if (!cNode.Children.ContainsKey(path_item)) { if (!Atoms.ContainsKey(cpath_str)) { cNode.Children[path_item] = this.Atoms[cpath_str]; } else { if (path_item.Contains('(')) { cNode.Children[path_item] = new Proc(cpath_str, new string[0], atom.Filename, atom.Line); } else { cNode.Children[path_item] = new Atom(cpath_str, atom.Filename, atom.Line); } } cNode.Children[path_item].Parent = cNode; string parent_type = cNode.Children[path_item].GetProperty <string>("parent_type", null); if (parent_type != null) { log.InfoFormat(" - Parent of {0} forced to be {1}", cNode.Children[path_item].Type.ToString(), parent_type); cNode.Children[path_item].Parent = this.Atoms[parent_type]; } } cNode = cNode.Children[path_item]; } } } this.Tree.InheritProperties(); log.InfoFormat("Processed {0} atoms.", this.Atoms.Count); // this.Atoms = {} }
/// <summary> /// Instantiate an atom. /// </summary> /// <param name="makeInitial">Create InitialProperties?</param> public Atom(string path, bool makeInitial = true) { Properties = new AtomProperties(this); this.Type = new BYONDType(path); if (makeInitial) { Properties.ClearDeltas(); } }