private bool CreateClasses(out IDictionary <IClass, ICSharpClass> classTable) { classTable = null; if (!ClassSplitting.Create(Compiler.LoadedRoot.ClassList, ErrorList, out IClassSplitting Splitting)) { return(false); } classTable = new Dictionary <IClass, ICSharpClass>(); ICSharpClass ClassAny = CSharpClass.Create(Class.ClassAny); classTable.Add(Class.ClassAny, ClassAny); ICSharpClass ClassAnyReference = CSharpClass.Create(Class.ClassAnyReference); classTable.Add(Class.ClassAnyReference, ClassAnyReference); ICSharpClass ClassAnyValue = CSharpClass.Create(Class.ClassAnyValue); classTable.Add(Class.ClassAnyValue, ClassAnyValue); foreach (IClass Class in Compiler.LoadedRoot.ClassList) { ICSharpClass NewCSharpClass = CSharpClass.Create(Class); classTable.Add(Class, NewCSharpClass); } foreach (KeyValuePair <IClass, ICSharpClass> Entry in classTable) { ICSharpClass Class = Entry.Value; if (GetBaseClass(Class, Splitting, classTable, out ICSharpClass BaseClass)) { Class.SetBaseClass(BaseClass); } Class.SetAncestorClasses(classTable); } foreach (KeyValuePair <IClass, ICSharpClass> Entry in classTable) { ICSharpClass Class = Entry.Value; CheckRename(Class, ErrorList); } if (!ErrorList.IsEmpty) { return(false); } return(true); }
/// <summary> /// Creates a <see cref="ClassSplitting"/> object. /// </summary> /// <param name="classList">The list of classes to split.</param> /// <param name="errorList">The list of errors found.</param> /// <param name="result">The created object upon return.</param> public static bool Create(IList <IClass> classList, IErrorList errorList, out IClassSplitting result) { result = new ClassSplitting(); foreach (IClass ClassItem in classList) { if (ClassItem.HasExternBody) { result.MustInherit.Add(ClassItem); } } foreach (IClass ClassItem in classList) { bool InheritanceForced = false; foreach (IInheritance InheritanceItem in ClassItem.InheritanceList) { IClassType ClassParentType = InheritanceItem.ResolvedClassParentType.Item; IClass BaseClass = ClassParentType.BaseClass; if (result.MustInherit.Contains(BaseClass)) { if (InheritanceForced) { errorList.AddError(new ErrorMultipleExternBody(ClassItem)); break; } else { InheritanceForced = true; } } } if (errorList.IsEmpty && InheritanceForced) { foreach (IInheritance InheritanceItem in ClassItem.InheritanceList) { IClassType ClassParentType = InheritanceItem.ResolvedClassParentType.Item; IClass BaseClass = ClassParentType.BaseClass; if (!result.MustInherit.Contains(BaseClass) && !result.MustInterface.Contains(BaseClass)) { result.MustInterface.Add(BaseClass); } } } } if (!errorList.IsEmpty) { return(false); } foreach (IClass ClassItem in classList) { if (!result.MustInherit.Contains(ClassItem) && !result.MustInterface.Contains(ClassItem)) { result.OtherParents.Add(ClassItem); } } return(true); }