[flang] checkpoint

Original-commit: flang-compiler/f18@e103152671
Reviewed-on: https://github.com/flang-compiler/f18/pull/212
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2018-10-05 09:57:53 -07:00
parent a70f596719
commit 75a32097fd
2 changed files with 30 additions and 6 deletions

View File

@ -807,11 +807,36 @@ struct IntrinsicTable::Implementation {
}
}
std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &) const;
semantics::IntrinsicTypeDefaultKinds defaults;
std::multimap<std::string, const IntrinsicInterface *> genericFuncs;
std::multimap<std::string, const SpecificIntrinsicInterface *> specificFuncs;
};
std::optional<SpecificIntrinsic> IntrinsicTable::Implementation::Probe(
const CallCharacteristics &call) const {
if (call.isSubroutineCall) {
return std::nullopt; // TODO
}
// Probe the specific intrinsic functions first.
std::string name{call.name.ToString()};
auto specificRange{specificFuncs.equal_range(name)};
for (auto iter{specificRange.first}; iter != specificRange.second; ++iter) {
if (auto specific{iter->second->Match(call, defaults)}) {
specific->name = iter->second->generic;
return specific;
}
}
auto genericRange{specificFuncs.equal_range(name)};
for (auto iter{genericRange.first}; iter != genericRange.second; ++iter) {
if (auto specific{iter->second->Match(call, defaults)}) {
return specific;
}
}
return std::nullopt;
}
IntrinsicTable::~IntrinsicTable() {
delete impl_;
impl_ = nullptr;
@ -825,10 +850,8 @@ IntrinsicTable IntrinsicTable::Configure(
}
std::optional<SpecificIntrinsic> IntrinsicTable::Probe(
const CallCharacteristics &call) {
const CallCharacteristics &call) const {
CHECK(impl_ != nullptr || !"IntrinsicTable: not configured");
if (call.isSubroutineCall) {
return std::nullopt; // TODO
}
return impl_->Probe(call);
}
} // namespace Fortran::evaluate

View File

@ -49,6 +49,7 @@ struct CallCharacteristics {
};
struct SpecificIntrinsic {
// SpecificIntrinsic(SpecificIntrinsic &&) = default;
explicit SpecificIntrinsic(const char *n) : name{n} {}
SpecificIntrinsic(const char *n, bool isElem, DynamicType dt, int r)
: name{n}, isElemental{isElem}, type{dt}, rank{r} {}
@ -65,10 +66,10 @@ private:
public:
~IntrinsicTable();
static IntrinsicTable Configure(const semantics::IntrinsicTypeDefaultKinds &);
std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &);
std::optional<SpecificIntrinsic> Probe(const CallCharacteristics &) const;
private:
Implementation *impl_{nullptr};
Implementation *impl_{nullptr}; // owning pointer
};
} // namespace Fortran::evaluate
#endif // FORTRAN_EVALUATE_INTRINSICS_H_