/// <summary> /// This function computes the Base class and also the /// list of interfaces that the class or struct @c implements. /// /// The return value is an array (might be null) of /// interfaces implemented (as Types). /// /// The @base_class argument is set to the base object or null /// if this is `System.Object'. /// </summary> protected virtual TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class) { // PlayScript will default to the "_root.Object" base class.. not null. if (this.Location.SourceFile != null && this.Location.SourceFile.FileType == SourceFileType.PlayScript && this is Class && !this.IsStatic) { base_class = new MemberAccess(new SimpleName(PsConsts.PsRootNamespace, Location), "Object"); base_type = base_class.ResolveAsType (new BaseContext (this)); if (base_type == null) base_class = null; } else { base_class = null; } if (type_bases == null) return null; int count = type_bases.Count; TypeSpec[] ifaces = null; var base_context = new BaseContext (this); for (int i = 0, j = 0; i < count; i++){ FullNamedExpression fne = type_bases [i]; var fne_resolved = fne.ResolveAsType (base_context); if (fne_resolved == null) continue; if (i == 0 && Kind == MemberKind.Class && !fne_resolved.IsInterface) { if (fne_resolved.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Report.Error (1965, Location, "Class `{0}' cannot derive from the dynamic type", GetSignatureForError ()); continue; } base_type = fne_resolved; base_class = fne; continue; } if (ifaces == null) ifaces = new TypeSpec [count - i]; if (fne_resolved.IsInterface) { for (int ii = 0; ii < j; ++ii) { if (fne_resolved == ifaces [ii]) { Report.Error (528, Location, "`{0}' is already listed in interface list", fne_resolved.GetSignatureForError ()); break; } } if (Kind == MemberKind.Interface && !IsAccessibleAs (fne_resolved)) { Report.Error (61, fne.Location, "Inconsistent accessibility: base interface `{0}' is less accessible than interface `{1}'", fne_resolved.GetSignatureForError (), GetSignatureForError ()); } } else { Report.SymbolRelatedToPreviousError (fne_resolved); if (Kind != MemberKind.Class) { Report.Error (527, fne.Location, "Type `{0}' in interface list is not an interface", fne_resolved.GetSignatureForError ()); } else if (base_class != null) Report.Error (1721, fne.Location, "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')", GetSignatureForError (), base_class.GetSignatureForError (), fne_resolved.GetSignatureForError ()); else { Report.Error (1722, fne.Location, "`{0}': Base class `{1}' must be specified as first", GetSignatureForError (), fne_resolved.GetSignatureForError ()); } } ifaces [j++] = fne_resolved; } return ifaces; }