private static void DefineCoolTypes() { #region Types Dictionary["Object"] = new CoolType("Object") { Parent = null }; Dictionary["IO"] = new CoolType("IO") { Parent = Dictionary["Object"] }; Dictionary["String"] = new CoolType("String", true) { Parent = Dictionary["Object"] }; Dictionary["Int"] = new CoolType("Int", true) { Parent = Dictionary["Object"] }; Dictionary["Bool"] = new CoolType("Bool", true) { Parent = Dictionary["Object"] }; #endregion #region Methods Dictionary["Object"] .Def_Method("abort", Dictionary["Object"]) .Def_Method("copy", Dictionary["Object"]) .Def_Method("type_name", Dictionary["String"]); Dictionary["IO"] .Def_Method("out_string", Dictionary["Object"], new[] { ("x", Dictionary["String"]) })
public static CoolType Lca(CoolType a, CoolType b) { var listTypes = new List <CoolType>(); while (a.Parent != null) { listTypes.Add(a); a = (CoolType)a.Parent; } while (b.Parent != null) { foreach (var type in listTypes) { if (b.Name != type.Name) { continue; } return(type); } b = (CoolType)b.Parent; } return(a); }