14
14
#ifndef LLVM_CLANG_INTERPRETER_INTERPRETER_H
15
15
#define LLVM_CLANG_INTERPRETER_INTERPRETER_H
16
16
17
- #include " clang/AST/Decl.h"
18
- #include " clang/AST/GlobalDecl.h"
19
17
#include " clang/Interpreter/PartialTranslationUnit.h"
20
- #include " clang/Interpreter/Value.h"
21
18
22
- #include " llvm/ADT/DenseMap.h"
19
+ #include " clang/AST/GlobalDecl.h"
20
+
23
21
#include " llvm/ExecutionEngine/JITSymbol.h"
24
22
#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
25
23
#include " llvm/Support/Error.h"
24
+
26
25
#include < memory>
27
26
#include < vector>
28
27
@@ -55,26 +54,24 @@ class Interpreter {
55
54
Interpreter (std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
56
55
57
56
llvm::Error CreateExecutor ();
58
- unsigned InitPTUSize = 0 ;
59
-
60
- // This member holds the last result of the value printing. It's a class
61
- // member because we might want to access it after more inputs. If no value
62
- // printing happens, it's in an invalid state.
63
- Value LastValue;
64
57
65
58
public:
66
59
~Interpreter ();
67
60
static llvm::Expected<std::unique_ptr<Interpreter>>
68
61
create (std::unique_ptr<CompilerInstance> CI);
69
- const ASTContext &getASTContext () const ;
70
- ASTContext &getASTContext ();
71
62
const CompilerInstance *getCompilerInstance () const ;
72
63
llvm::Expected<llvm::orc::LLJIT &> getExecutionEngine ();
73
64
74
65
llvm::Expected<PartialTranslationUnit &> Parse (llvm::StringRef Code);
75
66
llvm::Error Execute (PartialTranslationUnit &T);
76
- llvm::Error ParseAndExecute (llvm::StringRef Code, Value *V = nullptr );
77
- llvm::Expected<llvm::orc::ExecutorAddr> CompileDtorCall (CXXRecordDecl *CXXRD);
67
+ llvm::Error ParseAndExecute (llvm::StringRef Code) {
68
+ auto PTU = Parse (Code);
69
+ if (!PTU)
70
+ return PTU.takeError ();
71
+ if (PTU->TheModule )
72
+ return Execute (*PTU);
73
+ return llvm::Error::success ();
74
+ }
78
75
79
76
// / Undo N previous incremental inputs.
80
77
llvm::Error Undo (unsigned N = 1 );
@@ -95,23 +92,6 @@ class Interpreter {
95
92
// / file.
96
93
llvm::Expected<llvm::orc::ExecutorAddr>
97
94
getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const ;
98
-
99
- enum InterfaceKind { NoAlloc, WithAlloc, CopyArray };
100
-
101
- const llvm::SmallVectorImpl<Expr *> &getValuePrintingInfo () const {
102
- return ValuePrintingInfo;
103
- }
104
-
105
- Expr *SynthesizeExpr (Expr *E);
106
-
107
- private:
108
- size_t getEffectivePTUSize () const ;
109
-
110
- bool FindRuntimeInterface ();
111
-
112
- llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
113
-
114
- llvm::SmallVector<Expr *, 3 > ValuePrintingInfo;
115
95
};
116
96
} // namespace clang
117
97
0 commit comments