// type2 (except for kind type parameters)
static bool HaveCompatibleKindParameters(
const DerivedTypeSpec &derivedType1, const DerivedTypeSpec &derivedType2) {
- const DerivedTypeDetails &typeDetails{
- derivedType1.typeSymbol().get<DerivedTypeDetails>()};
for (const Symbol *symbol :
- typeDetails.OrderParameterDeclarations(derivedType1.typeSymbol())) {
+ OrderParameterDeclarations(derivedType1.typeSymbol())) {
if (symbol->get<TypeParamDetails>().attr() == common::TypeParamAttr::Kind) {
// At this point, it should have been ensured that these contain integer
// constants, so die if this is not the case.
// order as "type parameter order" (7.5.3.2).
// Parameters of the most deeply nested "base class" come first when the
// derived type is an extension.
- const DerivedTypeDetails &typeDetails{typeSymbol->get<DerivedTypeDetails>()};
- auto parameterNames{typeDetails.OrderParameterNames(*typeSymbol)};
- auto parameterDecls{typeDetails.OrderParameterDeclarations(*typeSymbol)};
+ auto parameterNames{OrderParameterNames(*typeSymbol)};
+ auto parameterDecls{OrderParameterDeclarations(*typeSymbol)};
auto nextNameIter{parameterNames.begin()};
bool seenAnyName{false};
for (const auto &typeParamSpec :
componentNames_.push_back(symbol.name());
}
-std::list<SourceName> DerivedTypeDetails::OrderParameterNames(
- const Symbol &type) const {
- std::list<SourceName> result;
- if (const DerivedTypeSpec * spec{type.GetParentTypeSpec()}) {
- const DerivedTypeDetails &details{
- spec->typeSymbol().get<DerivedTypeDetails>()};
- result = details.OrderParameterNames(spec->typeSymbol());
- }
- for (const auto &name : paramNames_) {
- result.push_back(name);
- }
- return result;
-}
-
-SymbolVector DerivedTypeDetails::OrderParameterDeclarations(
- const Symbol &type) const {
- SymbolVector result;
- if (const DerivedTypeSpec * spec{type.GetParentTypeSpec()}) {
- const DerivedTypeDetails &details{
- spec->typeSymbol().get<DerivedTypeDetails>()};
- result = details.OrderParameterDeclarations(spec->typeSymbol());
- }
- result.insert(result.end(), paramDecls_.begin(), paramDecls_.end());
- return result;
-}
-
SymbolVector DerivedTypeDetails::OrderComponents(const Scope &scope) const {
SymbolVector result;
for (SourceName name : componentNames_) {
void add_component(const Symbol &);
void set_sequence(bool x = true) { sequence_ = x; }
- // Returns the complete list of derived type parameter names in the
- // order defined by 7.5.3.2.
- std::list<SourceName> OrderParameterNames(const Symbol &) const;
-
- // Returns the complete list of derived type parameter symbols in
- // the order in which their declarations appear in the derived type
- // definitions (parents first).
- SymbolVector OrderParameterDeclarations(const Symbol &) const;
-
// Returns the complete list of derived type components in the order
// in which their declarations appear in the derived type definitions
// (parents first). Parent components appear in the list immediately
static Symbol &InstantiateSymbol(const Symbol &, Scope &, SemanticsContext &);
+std::list<SourceName> OrderParameterNames(const Symbol &typeSymbol) {
+ std::list<SourceName> result;
+ if (const DerivedTypeSpec * spec{typeSymbol.GetParentTypeSpec()}) {
+ result = OrderParameterNames(spec->typeSymbol());
+ }
+ const auto ¶mNames{typeSymbol.get<DerivedTypeDetails>().paramNames()};
+ result.insert(result.end(), paramNames.begin(), paramNames.end());
+ return result;
+}
+
+SymbolVector OrderParameterDeclarations(const Symbol &typeSymbol) {
+ SymbolVector result;
+ if (const DerivedTypeSpec * spec{typeSymbol.GetParentTypeSpec()}) {
+ result = OrderParameterDeclarations(spec->typeSymbol());
+ }
+ const auto ¶mDecls{typeSymbol.get<DerivedTypeDetails>().paramDecls()};
+ result.insert(result.end(), paramDecls.begin(), paramDecls.end());
+ return result;
+}
+
void InstantiateDerivedType(DerivedTypeSpec &spec, Scope &containingScope,
SemanticsContext &semanticsContext) {
Scope &newScope{containingScope.MakeScope(Scope::Kind::DerivedType)};
const Symbol &typeSymbol{spec.typeSymbol()};
const Scope *typeScope{typeSymbol.scope()};
CHECK(typeScope != nullptr);
- const auto &typeDetails{typeSymbol.get<DerivedTypeDetails>()};
- for (const Symbol *symbol :
- typeDetails.OrderParameterDeclarations(typeSymbol)) {
+ for (const Symbol *symbol : OrderParameterDeclarations(typeSymbol)) {
const SourceName &name{symbol->name()};
if (typeScope->find(symbol->name()) != typeScope->end()) {
// This type parameter belongs to the derived type itself, not to
void ProcessParameterExpressions(
DerivedTypeSpec &spec, evaluate::FoldingContext &foldingContext) {
- const Symbol &typeSymbol{spec.typeSymbol()};
- const DerivedTypeDetails &typeDetails{typeSymbol.get<DerivedTypeDetails>()};
- auto paramDecls{typeDetails.OrderParameterDeclarations(typeSymbol)};
+ auto paramDecls{OrderParameterDeclarations(spec.typeSymbol())};
// Fold the explicit type parameter value expressions first. Do not
// fold them within the scope of the derived type being instantiated;
// these expressions cannot use its type parameters. Convert the values
bool IsCoarray(const Symbol &symbol);
bool IsAssumedSizeArray(const Symbol &symbol);
+// Returns the complete list of derived type parameter symbols in
+// the order in which their declarations appear in the derived type
+// definitions (parents first).
+SymbolVector OrderParameterDeclarations(const Symbol &);
+// Returns the complete list of derived type parameter names in the
+// order defined by 7.5.3.2.
+std::list<SourceName> OrderParameterNames(const Symbol &);
+
// Create a new instantiation of this parameterized derived type
// for this particular distinct set of actual parameter values.
void InstantiateDerivedType(DerivedTypeSpec &, Scope &, SemanticsContext &);