// Kinds of IMPORT statements. Default means IMPORT or IMPORT :: names.
ENUM_CLASS(ImportKind, Default, Only, None, All)
-// Type parameters can be kind or len.
-ENUM_CLASS(TypeParamKindOrLen, Kind, Len)
+// The attribute on a type parameter can be KIND or LEN.
+ENUM_CLASS(TypeParamAttr, Kind, Len)
} // namespace Fortran::common
#endif // FORTRAN_COMMON_FORTRAN_H_
// integer-type-spec , type-param-attr-spec :: type-param-decl-list
// R734 type-param-attr-spec -> KIND | LEN
TYPE_PARSER(construct<TypeParamDefStmt>(integerTypeSpec / ",",
- "KIND" >> pure(common::TypeParamKindOrLen::Kind) ||
- "LEN" >> pure(common::TypeParamKindOrLen::Len),
+ "KIND" >> pure(common::TypeParamAttr::Kind) ||
+ "LEN" >> pure(common::TypeParamAttr::Len),
"::" >> nonemptyList(Parser<TypeParamDecl>{})))
// R733 type-param-decl -> type-param-name [= scalar-int-constant-expr]
// R734 type-param-attr-spec -> KIND | LEN
struct TypeParamDefStmt {
TUPLE_CLASS_BOILERPLATE(TypeParamDefStmt);
- std::tuple<IntegerTypeSpec, common::TypeParamKindOrLen,
- std::list<TypeParamDecl>>
+ std::tuple<IntegerTypeSpec, common::TypeParamAttr, std::list<TypeParamDecl>>
t;
};
}
void Unparse(const TypeParamDefStmt &x) { // R732
Walk(std::get<IntegerTypeSpec>(x.t));
- Put(", "), Walk(std::get<common::TypeParamKindOrLen>(x.t));
+ Put(", "), Walk(std::get<common::TypeParamAttr>(x.t));
Put(" :: "), Walk(std::get<std::list<TypeParamDecl>>(x.t), ", ");
}
void Unparse(const TypeParamDecl &x) { // R733
#define WALK_NESTED_ENUM(CLASS, ENUM) \
void Unparse(const CLASS::ENUM &x) { Word(CLASS::EnumToString(x)); }
WALK_NESTED_ENUM(AccessSpec, Kind) // R807
- WALK_NESTED_ENUM(common, TypeParamKindOrLen) // R734
+ WALK_NESTED_ENUM(common, TypeParamAttr) // R734
WALK_NESTED_ENUM(IntentSpec, Intent) // R826
WALK_NESTED_ENUM(ImplicitStmt, ImplicitNoneNameSpec) // R866
WALK_NESTED_ENUM(ConnectSpec::CharExpr, Kind) // R1205
NODE(parser::TypeGuardStmt, Guard)
NODE(parser, TypeParamDecl)
NODE(parser, TypeParamDefStmt)
- NODE(common, TypeParamKindOrLen)
+ NODE(common, TypeParamAttr)
NODE(parser, TypeParamInquiry)
NODE(parser, TypeParamSpec)
NODE(parser, TypeParamValue)
auto *type{symbol.GetType()};
CHECK(type);
PutLower(os, *type);
- PutLower(os << ',',
- common::EnumToString(symbol.get<TypeParamDetails>().kindOrLen()));
+ PutLower(
+ os << ',', common::EnumToString(symbol.get<TypeParamDetails>().attr()));
});
}
// Provide Post methods to collect attributes into a member variable.
class AttrsVisitor {
public:
- bool BeginAttrs();
+ bool BeginAttrs(); // always returns true
Attrs GetAttrs();
Attrs EndAttrs();
void Post(const parser::LanguageBindingSpec &);
}
void DeclarationVisitor::Post(const parser::TypeParamDefStmt &x) {
auto &type{GetDeclTypeSpec()};
- auto kindOrLen{std::get<common::TypeParamKindOrLen>(x.t)};
+ auto attr{std::get<common::TypeParamAttr>(x.t)};
for (auto &decl : std::get<std::list<parser::TypeParamDecl>>(x.t)) {
auto &name{std::get<parser::Name>(decl.t).source};
// TODO: initialization
// auto &init{
// std::get<std::optional<parser::ScalarIntConstantExpr>>(decl.t)};
- auto &symbol{MakeTypeSymbol(name, TypeParamDetails{kindOrLen})};
+ auto &symbol{MakeTypeSymbol(name, TypeParamDetails{attr})};
SetType(name, symbol, *type);
}
EndDecl();
if (x.type()) {
os << ' ' << *x.type();
}
- os << ' ' << common::EnumToString(x.kindOrLen());
+ os << ' ' << common::EnumToString(x.attr());
},
},
details);
class TypeParamDetails {
public:
- TypeParamDetails(common::TypeParamKindOrLen kindOrLen)
- : kindOrLen_{kindOrLen} {}
- common::TypeParamKindOrLen kindOrLen() const { return kindOrLen_; }
+ TypeParamDetails(common::TypeParamAttr attr) : attr_{attr} {}
+ common::TypeParamAttr attr() const { return attr_; }
const std::optional<DeclTypeSpec> &type() const { return type_; }
void set_type(const DeclTypeSpec &type) {
CHECK(!type_);
}
private:
- common::TypeParamKindOrLen kindOrLen_;
+ common::TypeParamAttr attr_;
std::optional<DeclTypeSpec> type_;
};