-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathSILGenRequests.cpp
72 lines (65 loc) · 2.39 KB
/
SILGenRequests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//===--- Condition.cpp - Implements the SILGen Condition class ------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/AST/SILGenRequests.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/Module.h"
#include "swift/AST/FileUnit.h"
#include "swift/AST/SourceFile.h"
#include "swift/SIL/SILModule.h"
#include "swift/Subsystems.h"
using namespace swift;
namespace swift {
// Implement the SILGen type zone (zone 12).
#define SWIFT_TYPEID_ZONE SILGen
#define SWIFT_TYPEID_HEADER "swift/AST/SILGenTypeIDZone.def"
#include "swift/Basic/ImplementTypeIDZone.h"
#undef SWIFT_TYPEID_ZONE
#undef SWIFT_TYPEID_HEADER
} // end namespace swift
void swift::simple_display(llvm::raw_ostream &out,
const SILGenDescriptor &desc) {
auto *MD = desc.context.dyn_cast<ModuleDecl *>();
auto *unit = desc.context.dyn_cast<FileUnit *>();
if (MD) {
out << "SIL Generation for module " << MD->getName();
} else {
assert(unit);
out << "SIL Generation for file ";
switch (unit->getKind()) {
case FileUnitKind::Source:
out << '\"' << cast<SourceFile>(unit)->getFilename() << '\"';
break;
case FileUnitKind::Builtin:
out << "(Builtin)";
break;
case FileUnitKind::DWARFModule:
case FileUnitKind::ClangModule:
case FileUnitKind::SerializedAST:
out << '\"' << cast<LoadedFile>(unit)->getFilename() << '\"';
break;
}
}
}
SourceLoc swift::extractNearestSourceLoc(const SILGenDescriptor &desc) {
return SourceLoc();
}
// Define request evaluation functions for each of the SILGen requests.
static AbstractRequestFunction *silGenRequestFunctions[] = {
#define SWIFT_REQUEST(Zone, Name, Sig, Caching, LocOptions) \
reinterpret_cast<AbstractRequestFunction *>(&Name::evaluateRequest),
#include "swift/AST/SILGenTypeIDZone.def"
#undef SWIFT_REQUEST
};
void swift::registerSILGenRequestFunctions(Evaluator &evaluator) {
evaluator.registerRequestFunctions(Zone::SILGen,
silGenRequestFunctions);
}