From af25718ecde272ff19578ee7287125bcea337920 Mon Sep 17 00:00:00 2001 From: Stephane Chauveau Date: Thu, 12 Apr 2018 17:11:31 +0200 Subject: [PATCH] [flang] Add missing accessors in 'type' classes Original-commit: flang-compiler/f18@42a46f35e82661e0f0a2c62d12448072dabcd5f7 Reviewed-on: https://github.com/flang-compiler/f18/pull/51 Tree-same-pre-rewrite: false --- flang/lib/semantics/type.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/flang/lib/semantics/type.h b/flang/lib/semantics/type.h index b907815..9d2d19d2 100644 --- a/flang/lib/semantics/type.h +++ b/flang/lib/semantics/type.h @@ -60,6 +60,7 @@ public: bool operator==(const IntConst &x) const { return value_ == x.value_; } bool operator!=(const IntConst &x) const { return !operator==(x); } bool operator<(const IntConst &x) const { return value_ < x.value_; } + std::uint64_t value() const { return value_; } std::ostream &Output(std::ostream &o) const { return o << this->value_; } @@ -78,6 +79,7 @@ public: bool operator==(const KindParamValue &x) const { return value_ == x.value_; } bool operator!=(const KindParamValue &x) const { return !operator==(x); } bool operator<(const KindParamValue &x) const { return value_ < x.value_; } + const IntConst & value() const { return value_; } private: const IntConst &value_; @@ -270,6 +272,7 @@ public: static const int DefaultKind = 0; CharacterTypeSpec(LenParamValue len, KindParamValue kind = DefaultKind) : IntrinsicTypeSpec{kind}, len_{len} {} + const LenParamValue & len() const { return len_ ; } std::ostream &Output(std::ostream &o) const override { return o << *this; } private: @@ -324,7 +327,10 @@ public: bool isExplicit() const { return ub_.isExplicit(); } bool isDeferred() const { return lb_.isDeferred(); } - + + const Bound & lbound() const { return lb_; } + const Bound & ubound() const { return ub_; } + private: ShapeSpec(const Bound &lb, const Bound &ub) : lb_{lb}, ub_{ub} {} const Bound lb_; @@ -346,6 +352,11 @@ public: DataComponentDef(const DeclTypeSpec &type, const Name &name, const Attrs &attrs, const ComponentArraySpec &arraySpec); + const DeclTypeSpec & type() const { return type_; } + const Name & name() const { return name_; } + const Attrs & attrs() const { return attrs_; } + const ComponentArraySpec & shape() const { return arraySpec_; } + private: const DeclTypeSpec type_; const Name name_; @@ -358,6 +369,7 @@ class ProcDecl { public: ProcDecl(const Name &name) : name_{name} {} // TODO: proc-pointer-init + const Name & name() const { return name_; } private: const Name name_; friend std::ostream &operator<<(std::ostream &, const ProcDecl &); @@ -371,6 +383,11 @@ public: : ProcComponentDef(decl, attrs, interfaceName, std::nullopt) {} ProcComponentDef(ProcDecl decl, Attrs attrs, const DeclTypeSpec &typeSpec) : ProcComponentDef(decl, attrs, std::nullopt, typeSpec) {} + + const ProcDecl & decl() const { return decl_ ;} + const Attrs & attrs() const { return attrs_; } + const std::optional & interfaceName() const { return interfaceName_; } + const std::optional & typeSpec() const { return typeSpec_; } private: ProcComponentDef(ProcDecl decl, Attrs attrs, @@ -390,6 +407,7 @@ class DerivedTypeDef { public: const Name &name() const { return data_.name; } const std::optional &extends() const { return data_.extends; } + const Attrs & attrs() const { return data_.attrs; } const TypeParamDefs &lenParams() const { return data_.lenParams; } const TypeParamDefs &kindParams() const { return data_.kindParams; } const std::list &dataComponents() const { @@ -455,6 +473,10 @@ public: paramValues_.push_back(std::make_pair(name, value)); return *this; } + + const std::list, ParamValue>> & paramValues() { + return paramValues_; + } private: const Name name_; -- 2.7.4