}
}
-// Trait-determined traversal of empty, tuple, union, and wrapper classes.
+// Trait-determined traversal of empty, tuple, union, wrapper,
+// and constraint-checking classes.
template<typename A, typename V>
std::enable_if_t<EmptyTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
}
}
-template<typename T, typename V>
-void Walk(const common::Indirection<T> &x, V &visitor) {
- Walk(x.value(), visitor);
-}
-template<typename T, typename M>
-void Walk(common::Indirection<T> &x, M &mutator) {
- Walk(x.value(), mutator);
-}
-
-// Walk a class with a single field 'thing'.
-template<typename T, typename V> void Walk(const Scalar<T> &x, V &visitor) {
- if (visitor.Pre(x)) {
- Walk(x.thing, visitor);
- visitor.Post(x);
- }
-}
-template<typename T, typename M> void Walk(Scalar<T> &x, M &mutator) {
- if (mutator.Pre(x)) {
- Walk(x.thing, mutator);
- mutator.Post(x);
- }
-}
-template<typename T, typename V> void Walk(const Constant<T> &x, V &visitor) {
- if (visitor.Pre(x)) {
- Walk(x.thing, visitor);
- visitor.Post(x);
- }
-}
-template<typename T, typename M> void Walk(Constant<T> &x, M &mutator) {
- if (mutator.Pre(x)) {
- Walk(x.thing, mutator);
- mutator.Post(x);
- }
-}
-template<typename T, typename V> void Walk(const Integer<T> &x, V &visitor) {
- if (visitor.Pre(x)) {
- Walk(x.thing, visitor);
- visitor.Post(x);
- }
-}
-template<typename T, typename M> void Walk(Integer<T> &x, M &mutator) {
- if (mutator.Pre(x)) {
- Walk(x.thing, mutator);
- mutator.Post(x);
- }
-}
-template<typename T, typename V> void Walk(const Logical<T> &x, V &visitor) {
+template<typename A, typename V>
+std::enable_if_t<ConstraintTrait<A>> Walk(const A &x, V &visitor) {
if (visitor.Pre(x)) {
Walk(x.thing, visitor);
visitor.Post(x);
}
}
-template<typename T, typename M> void Walk(Logical<T> &x, M &mutator) {
+template<typename A, typename M>
+std::enable_if_t<ConstraintTrait<A>> Walk(A &x, M &mutator) {
if (mutator.Pre(x)) {
Walk(x.thing, mutator);
mutator.Post(x);
}
}
+
template<typename T, typename V>
-void Walk(const DefaultChar<T> &x, V &visitor) {
- if (visitor.Pre(x)) {
- Walk(x.thing, visitor);
- visitor.Post(x);
- }
+void Walk(const common::Indirection<T> &x, V &visitor) {
+ Walk(x.value(), visitor);
}
-template<typename T, typename M> void Walk(DefaultChar<T> &x, M &mutator) {
- if (mutator.Pre(x)) {
- Walk(x.thing, mutator);
- mutator.Post(x);
- }
+template<typename T, typename M>
+void Walk(common::Indirection<T> &x, M &mutator) {
+ Walk(x.value(), mutator);
}
template<typename T, typename V> void Walk(const Statement<T> &x, V &visitor) {
auto dynamicType{expr.v.GetType()};
return dynamicType.has_value() && dynamicType->category == type;
}
-
-static parser::Name *GetSimpleName(
- common::Indirection<parser::Designator> *designator) {
- if (designator) {
- auto *dataRef{std::get_if<parser::DataRef>(&designator->value().u)};
- return dataRef ? std::get_if<parser::Name>(&dataRef->u) : nullptr;
- } else {
- return nullptr;
- }
-}
-
-parser::Name *GetSimpleName(parser::Expr &expr) {
- return GetSimpleName(
- std::get_if<common::Indirection<parser::Designator>>(&expr.u));
-}
-const parser::Name *GetSimpleName(const parser::Expr &expr) {
- return GetSimpleName(const_cast<parser::Expr &>(expr));
-}
-
-parser::Name *GetSimpleName(parser::Variable &variable) {
- return GetSimpleName(
- std::get_if<common::Indirection<parser::Designator>>(&variable.u));
-}
-const parser::Name *GetSimpleName(const parser::Variable &variable) {
- return GetSimpleName(const_cast<parser::Variable &>(variable));
-}
-
}