forked from OSchip/llvm-project
[flang] Pull indirection into some constructors.
Original-commit: flang-compiler/f18@074e249499 Reviewed-on: https://github.com/flang-compiler/f18/pull/144 Tree-same-pre-rewrite: false
This commit is contained in:
parent
2f8baf1835
commit
7dbc09357e
|
@ -196,7 +196,6 @@ Expr<Category::Integer, KIND>::ConstantValue() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
|
||||
template<int KIND>
|
||||
void Expr<Category::Integer, KIND>::Fold(FoldingContext &context) {
|
||||
std::visit(common::visitors{[&](Parentheses &p) {
|
||||
|
|
|
@ -93,8 +93,8 @@ template<> std::ostream &Emit(std::ostream &o, const IntrinsicProcedure &p) {
|
|||
}
|
||||
|
||||
std::ostream &Component::Dump(std::ostream &o) const {
|
||||
base->Dump(o);
|
||||
return Emit(o << '%', sym);
|
||||
base_->Dump(o);
|
||||
return Emit(o << '%', symbol_);
|
||||
}
|
||||
|
||||
std::ostream &Triplet::Dump(std::ostream &o) const {
|
||||
|
@ -238,20 +238,20 @@ SubscriptIntegerExpr Substring::Last() const {
|
|||
}
|
||||
|
||||
// LEN()
|
||||
static SubscriptIntegerExpr SymbolLEN(const Symbol *sym) {
|
||||
static SubscriptIntegerExpr SymbolLEN(const Symbol &sym) {
|
||||
return SubscriptIntegerExpr{0}; // TODO
|
||||
}
|
||||
SubscriptIntegerExpr Component::LEN() const { return SymbolLEN(sym); }
|
||||
SubscriptIntegerExpr Component::LEN() const { return SymbolLEN(symbol()); }
|
||||
SubscriptIntegerExpr ArrayRef::LEN() const {
|
||||
return std::visit(
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(s); },
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(*s); },
|
||||
[](const Component &x) { return x.LEN(); }},
|
||||
u);
|
||||
}
|
||||
SubscriptIntegerExpr CoarrayRef::LEN() const { return SymbolLEN(base.back()); }
|
||||
SubscriptIntegerExpr CoarrayRef::LEN() const { return SymbolLEN(*base.back()); }
|
||||
SubscriptIntegerExpr DataRef::LEN() const {
|
||||
return std::visit(
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(s); },
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(*s); },
|
||||
[](const auto &x) { return x.LEN(); }},
|
||||
u);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ SubscriptIntegerExpr Substring::LEN() const {
|
|||
}
|
||||
SubscriptIntegerExpr ProcedureDesignator::LEN() const {
|
||||
return std::visit(
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(s); },
|
||||
common::visitors{[](const Symbol *s) { return SymbolLEN(*s); },
|
||||
[](const Component &c) { return c.LEN(); },
|
||||
[](const auto &) {
|
||||
CRASH_NO_CASE;
|
||||
|
|
|
@ -50,16 +50,24 @@ using IndirectSubscriptIntegerExpr = CopyableIndirection<SubscriptIntegerExpr>;
|
|||
// that isn't explicit in the document). Pointer and allocatable components
|
||||
// are not explicitly indirected in this representation.
|
||||
// Complex components (%RE, %IM) are isolated below in ComplexPart.
|
||||
struct Component {
|
||||
class Component {
|
||||
public:
|
||||
CLASS_BOILERPLATE(Component)
|
||||
Component(const DataRef &b, const Symbol &c) : base{b}, sym{&c} {}
|
||||
Component(const DataRef &b, const Symbol &c) : base_{b}, symbol_{&c} {}
|
||||
Component(DataRef &&b, const Symbol &c) : base_{std::move(b)}, symbol_{&c} {}
|
||||
Component(CopyableIndirection<DataRef> &&b, const Symbol &c)
|
||||
: base{std::move(b)}, sym{&c} {}
|
||||
: base_{std::move(b)}, symbol_{&c} {}
|
||||
const DataRef &base() const { return *base_; }
|
||||
DataRef &base() { return *base_; }
|
||||
const Symbol &symbol() const { return *symbol_; }
|
||||
SubscriptIntegerExpr LEN() const;
|
||||
CopyableIndirection<DataRef> base;
|
||||
const Symbol *sym;
|
||||
private:
|
||||
CopyableIndirection<DataRef> base_;
|
||||
const Symbol *symbol_;
|
||||
};
|
||||
|
||||
// TODO pmk continue data hiding from here...
|
||||
|
||||
// R921 subscript-triplet
|
||||
struct Triplet {
|
||||
CLASS_BOILERPLATE(Triplet)
|
||||
|
|
Loading…
Reference in New Issue