9#ifndef FORTRAN_EVALUATE_CALL_H_
10#define FORTRAN_EVALUATE_CALL_H_
14#include "formatting.h"
16#include "flang/Common/Fortran.h"
17#include "flang/Common/indirection.h"
18#include "flang/Common/reference.h"
19#include "flang/Parser/char-block.h"
20#include "flang/Semantics/attr.h"
28namespace Fortran::semantics {
36class IntrinsicProcTable;
38namespace Fortran::evaluate::characteristics {
50using semantics::Symbol;
51using SymbolRef = common::Reference<const Symbol>;
55 ENUM_CLASS(Attr, PassedObject, PercentVal, PercentRef);
65 const Symbol &symbol()
const {
return symbol_; }
68 return &*symbol_ == &*that.symbol_;
70 llvm::raw_ostream &AsFortran(llvm::raw_ostream &)
const;
86 std::get_if<common::CopyableIndirection<Expr<SomeType>>>(&u_)}) {
92 const Expr<SomeType> *UnwrapExpr()
const {
94 std::get_if<common::CopyableIndirection<Expr<SomeType>>>(&u_)}) {
101 const Symbol *GetAssumedTypeDummy()
const {
102 if (
const AssumedType * aType{std::get_if<AssumedType>(&u_)}) {
103 return &aType->symbol();
109 common::Label GetLabel()
const {
return std::get<common::Label>(u_); }
111 std::optional<DynamicType> GetType()
const;
113 bool operator==(
const ActualArgument &)
const;
114 llvm::raw_ostream &AsFortran(llvm::raw_ostream &)
const;
116 std::optional<parser::CharBlock> keyword()
const {
return keyword_; }
117 ActualArgument &set_keyword(parser::CharBlock x) {
121 bool isAlternateReturn()
const {
122 return std::holds_alternative<common::Label>(u_);
124 bool isPassedObject()
const {
return attrs_.test(Attr::PassedObject); }
125 ActualArgument &set_isPassedObject(
bool yes =
true) {
127 attrs_ = attrs_ + Attr::PassedObject;
129 attrs_ = attrs_ - Attr::PassedObject;
135 common::Intent dummyIntent()
const {
return dummyIntent_; }
136 ActualArgument &set_dummyIntent(common::Intent intent) {
137 dummyIntent_ = intent;
140 std::optional<parser::CharBlock> sourceLocation()
const {
141 return sourceLocation_;
143 ActualArgument &set_sourceLocation(std::optional<parser::CharBlock> at) {
144 sourceLocation_ = at;
152 bool isPercentVal()
const {
return attrs_.test(Attr::PercentVal); };
153 ActualArgument &set_isPercentVal() {
154 attrs_ = attrs_ + Attr::PercentVal;
158 bool isPercentRef()
const {
return attrs_.test(Attr::PercentRef); };
159 ActualArgument &set_isPercentRef() {
160 attrs_ = attrs_ + Attr::PercentRef;
170 std::variant<common::CopyableIndirection<Expr<SomeType>>, AssumedType,
173 std::optional<parser::CharBlock> keyword_;
175 common::Intent dummyIntent_{common::Intent::Default};
176 std::optional<parser::CharBlock> sourceLocation_;
179using ActualArguments = std::vector<std::optional<ActualArgument>>;
183using IntrinsicProcedure = std::string;
190 llvm::raw_ostream &AsFortran(llvm::raw_ostream &)
const;
192 IntrinsicProcedure name;
193 bool isRestrictedSpecific{
false};
205 const Symbol *GetSymbol()
const;
206 const SymbolRef *UnwrapSymbolRef()
const;
215 const Symbol *GetInterfaceSymbol()
const;
217 std::string GetName()
const;
218 std::optional<DynamicType> GetType()
const;
220 bool IsElemental()
const;
222 std::optional<Expr<SubscriptInteger>> LEN()
const;
223 llvm::raw_ostream &AsFortran(llvm::raw_ostream &)
const;
230using Chevrons = std::vector<Expr<SomeType>>;
236 bool hasAlternateReturns =
false)
237 : proc_{std::move(p)}, arguments_{std::move(a)},
238 hasAlternateReturns_{hasAlternateReturns} {}
244 ActualArguments &arguments() {
return arguments_; }
245 const ActualArguments &arguments()
const {
return arguments_; }
247 Chevrons &chevrons() {
return chevrons_; }
248 const Chevrons &chevrons()
const {
return chevrons_; }
249 void set_chevrons(Chevrons &&chevrons) { chevrons_ = std::move(chevrons); }
251 std::optional<Expr<SubscriptInteger>> LEN()
const;
253 static constexpr int Corank() {
return 0; }
254 bool IsElemental()
const {
return proc_.IsElemental(); }
255 bool hasAlternateReturns()
const {
return hasAlternateReturns_; }
258 if (
static_cast<std::size_t
>(n) < arguments_.size() && arguments_[n]) {
259 return arguments_[n]->UnwrapExpr();
265 if (
static_cast<std::size_t
>(n) < arguments_.size() && arguments_[n]) {
266 return arguments_[n]->UnwrapExpr();
273 llvm::raw_ostream &AsFortran(llvm::raw_ostream &)
const;
277 ActualArguments arguments_;
279 bool hasAlternateReturns_;
290 std::optional<DynamicType> GetType()
const {
291 if constexpr (IsLengthlessIntrinsicType<A>) {
293 }
else if (
auto type{proc_.GetType()}) {
299 return type->DropNonConstantCharacterLength();
Definition: indirection.h:72
Definition: indirection.h:31
Definition: variable.h:74
Definition: characteristics.h:282
Definition: characteristics.h:355