|
| 1 | +//===------- ConstExtractRequests.h - Extraction Requests ------*- C++ -*-===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2021 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +// |
| 13 | +// This file defines const-extraction requests. |
| 14 | +// |
| 15 | +//===----------------------------------------------------------------------===// |
| 16 | +#ifndef SWIFT_CONST_EXTRACT_REQUESTS_H |
| 17 | +#define SWIFT_CONST_EXTRACT_REQUESTS_H |
| 18 | + |
| 19 | +#include "swift/AST/SimpleRequest.h" |
| 20 | +#include "swift/AST/ASTTypeIDs.h" |
| 21 | +#include "swift/AST/ConstTypeInfo.h" |
| 22 | +#include "swift/AST/EvaluatorDependencies.h" |
| 23 | +#include "swift/AST/FileUnit.h" |
| 24 | +#include "swift/AST/Identifier.h" |
| 25 | +#include "swift/AST/NameLookup.h" |
| 26 | +#include "swift/Basic/Statistic.h" |
| 27 | +#include "llvm/ADT/Hashing.h" |
| 28 | +#include "llvm/ADT/TinyPtrVector.h" |
| 29 | + |
| 30 | +namespace swift { |
| 31 | + |
| 32 | +class Decl; |
| 33 | +class DeclName; |
| 34 | +class EnumDecl; |
| 35 | + |
| 36 | +/// Retrieve information about compile-time-known values |
| 37 | +class ConstantValueInfoRequest |
| 38 | + : public SimpleRequest<ConstantValueInfoRequest, |
| 39 | + ConstValueTypeInfo(NominalTypeDecl *), |
| 40 | + RequestFlags::Cached> { |
| 41 | +public: |
| 42 | + using SimpleRequest::SimpleRequest; |
| 43 | + |
| 44 | +private: |
| 45 | + friend SimpleRequest; |
| 46 | + |
| 47 | + // Evaluation. |
| 48 | + ConstValueTypeInfo |
| 49 | + evaluate(Evaluator &eval, NominalTypeDecl *nominal) const; |
| 50 | + |
| 51 | +public: |
| 52 | + // Caching |
| 53 | + bool isCached() const { return true; } |
| 54 | +}; |
| 55 | + |
| 56 | +#define SWIFT_TYPEID_ZONE ConstExtract |
| 57 | +#define SWIFT_TYPEID_HEADER "swift/ConstExtract/ConstExtractTypeIDZone.def" |
| 58 | +#include "swift/Basic/DefineTypeIDZone.h" |
| 59 | +#undef SWIFT_TYPEID_ZONE |
| 60 | +#undef SWIFT_TYPEID_HEADER |
| 61 | + |
| 62 | +// Set up reporting of evaluated requests. |
| 63 | +template<typename Request> |
| 64 | +void reportEvaluatedRequest(UnifiedStatsReporter &stats, |
| 65 | + const Request &request); |
| 66 | + |
| 67 | +#define SWIFT_REQUEST(Zone, RequestType, Sig, Caching, LocOptions) \ |
| 68 | + template <> \ |
| 69 | + inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \ |
| 70 | + const RequestType &request) { \ |
| 71 | + ++stats.getFrontendCounters().RequestType; \ |
| 72 | + } |
| 73 | +#include "swift/ConstExtract/ConstExtractTypeIDZone.def" |
| 74 | +#undef SWIFT_REQUEST |
| 75 | + |
| 76 | +} // end namespace swift |
| 77 | + |
| 78 | +#endif // SWIFT_CONST_EXTRACT_REQUESTS_H |
| 79 | + |
0 commit comments