CppInterOp
C++ Language Interoperability Layer
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
CppInternal::Interpreter Class Reference

CppInterOp Interpreter. More...

#include "lib/CppInterOp/CppInterOpInterpreter.h"

Classes

struct  FileDeleter
 
struct  IOContext
 

Public Types

enum  CompilationResult { kSuccess , kFailure , kMoreInputExpected }
 Describes the return result of the different routines that do the incremental compilation. More...
 

Public Member Functions

 Interpreter (std::unique_ptr< clang::Interpreter > CI, std::unique_ptr< IOContext > ctx=nullptr, bool oop=false)
 
 ~Interpreter ()
 
 operator const clang::Interpreter & () const
 
 operator clang::Interpreter & ()
 
bool isOutOfProcess () const
 
FILE * getRedirectionFileForOutOfProcess (int FD)
 
const clang::CompilerInstance * getCompilerInstance () const
 
llvm::orc::LLJIT * getExecutionEngine () const
 
llvm::Expected< clang::PartialTranslationUnit & > Parse (llvm::StringRef Code)
 
llvm::Error Execute (clang::PartialTranslationUnit &T)
 
llvm::Error ParseAndExecute (llvm::StringRef Code, clang::Value *V=nullptr)
 
llvm::Error Undo (unsigned N=1)
 
void makeEngineOnce () const
 
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress (clang::GlobalDecl GD) const
 
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress (llvm::StringRef IRName) const
 
llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddressFromLinkerName (llvm::StringRef LinkerName) const
 
bool isInSyntaxOnlyMode () const
 
void * getAddressOfGlobal (const clang::GlobalDecl &GD) const
 
void * getAddressOfGlobal (llvm::StringRef SymName) const
 
CompilationResult declare (const std::string &input, clang::PartialTranslationUnit **PTU=nullptr)
 
CompilationResult process (const std::string &input, clang::Value *V=0, clang::PartialTranslationUnit **PTU=nullptr, bool disableValuePrinting=false)
 Maybe transform the input line to implement cint command line semantics (declarations are global) and compile to produce a module.
 
CompilationResult evaluate (const std::string &input, clang::Value &V)
 
void * compileFunction (llvm::StringRef name, llvm::StringRef code, bool ifUnique, bool withAccessControl)
 
const clang::CompilerInstance * getCI () const
 
clang::Sema & getSema () const
 
const DynamicLibraryManagergetDynamicLibraryManager () const
 
DynamicLibraryManagergetDynamicLibraryManager ()
 
void AddIncludePaths (llvm::StringRef PathsStr, const char *Delim=":")
 Adds multiple include paths separated by a delimiter.
 
void AddIncludePath (llvm::StringRef PathsStr)
 Adds a single include path (-I).
 
void GetIncludePaths (llvm::SmallVectorImpl< std::string > &incpaths, bool withSystem, bool withFlags) const
 Get the current include paths that are used.
 
CompilationResult loadLibrary (const std::string &filename, bool lookup)
 
std::string toString (const char *type, void *obj)
 
CompilationResult undo (unsigned N=1)
 

Static Public Member Functions

static std::unique_ptr< Interpretercreate (int argc, const char *const *argv, const char *llvmdir=nullptr, const std::vector< std::shared_ptr< clang::ModuleFileExtension > > &moduleExtensions={}, void *extraLibHandle=nullptr, bool noRuntime=true)
 

Detailed Description

CppInterOp Interpreter.

Definition at line 149 of file CppInterOpInterpreter.h.

Member Enumeration Documentation

◆ CompilationResult

Describes the return result of the different routines that do the incremental compilation.

Enumerator
kSuccess 
kFailure 
kMoreInputExpected 

Definition at line 284 of file CppInterOpInterpreter.h.

Constructor & Destructor Documentation

◆ Interpreter()

CppInternal::Interpreter::Interpreter ( std::unique_ptr< clang::Interpreter >  CI,
std::unique_ptr< IOContext ctx = nullptr,
bool  oop = false 
)
inline

◆ ~Interpreter()

CppInternal::Interpreter::~Interpreter ( )
inline

Definition at line 252 of file CppInterOpInterpreter.h.

Member Function Documentation

◆ AddIncludePath()

void CppInternal::Interpreter::AddIncludePath ( llvm::StringRef  PathsStr)
inline

Adds a single include path (-I).

Definition at line 499 of file CppInterOpInterpreter.h.

References AddIncludePaths().

Referenced by Cpp::AddIncludePath().

◆ AddIncludePaths()

void CppInternal::Interpreter::AddIncludePaths ( llvm::StringRef  PathsStr,
const char *  Delim = ":" 
)
inline

Adds multiple include paths separated by a delimiter.

Parameters
[in]PathsStr- Path(s)
[in]Delim- Delimiter to separate paths or NULL if a single path

Definition at line 472 of file CppInterOpInterpreter.h.

References CppInternal::utils::AddIncludePaths(), and getCompilerInstance().

Referenced by AddIncludePath().

◆ compileFunction()

void * CppInternal::Interpreter::compileFunction ( llvm::StringRef  name,
llvm::StringRef  code,
bool  ifUnique,
bool  withAccessControl 
)
inline

◆ create()

static std::unique_ptr< Interpreter > CppInternal::Interpreter::create ( int  argc,
const char *const *  argv,
const char *  llvmdir = nullptr,
const std::vector< std::shared_ptr< clang::ModuleFileExtension > > &  moduleExtensions = {},
void *  extraLibHandle = nullptr,
bool  noRuntime = true 
)
inlinestatic

Definition at line 210 of file CppInterOpInterpreter.h.

Referenced by Cpp::CreateInterpreter().

◆ declare()

CompilationResult CppInternal::Interpreter::declare ( const std::string &  input,
clang::PartialTranslationUnit **  PTU = nullptr 
)
inline

Definition at line 377 of file CppInterOpInterpreter.h.

References process().

Referenced by Cpp::Declare().

◆ evaluate()

CompilationResult CppInternal::Interpreter::evaluate ( const std::string &  input,
clang::Value &  V 
)
inline

Definition at line 406 of file CppInterOpInterpreter.h.

References kFailure, kSuccess, and ParseAndExecute().

Referenced by Cpp::Evaluate().

◆ Execute()

llvm::Error CppInternal::Interpreter::Execute ( clang::PartialTranslationUnit &  T)
inline

Definition at line 298 of file CppInterOpInterpreter.h.

Referenced by Cpp::ForceCodeGen(), and process().

◆ getAddressOfGlobal() [1/2]

void * CppInternal::Interpreter::getAddressOfGlobal ( const clang::GlobalDecl &  GD) const
inline

Definition at line 355 of file CppInterOpInterpreter.h.

References getSymbolAddress().

Referenced by compileFunction(), and Cpp::GetVariableOffset().

◆ getAddressOfGlobal() [2/2]

void * CppInternal::Interpreter::getAddressOfGlobal ( llvm::StringRef  SymName) const
inline

◆ getCI()

const clang::CompilerInstance * CppInternal::Interpreter::getCI ( ) const
inline

◆ getCompilerInstance()

const clang::CompilerInstance * CppInternal::Interpreter::getCompilerInstance ( ) const
inline

◆ getDynamicLibraryManager() [1/2]

DynamicLibraryManager * CppInternal::Interpreter::getDynamicLibraryManager ( )
inline

Definition at line 462 of file CppInterOpInterpreter.h.

References getDynamicLibraryManager().

◆ getDynamicLibraryManager() [2/2]

const DynamicLibraryManager * CppInternal::Interpreter::getDynamicLibraryManager ( ) const
inline

◆ getExecutionEngine()

llvm::orc::LLJIT * CppInternal::Interpreter::getExecutionEngine ( ) const
inline

Definition at line 290 of file CppInterOpInterpreter.h.

References compat::getExecutionEngine().

◆ GetIncludePaths()

void CppInternal::Interpreter::GetIncludePaths ( llvm::SmallVectorImpl< std::string > &  incpaths,
bool  withSystem,
bool  withFlags 
) const
inline

Get the current include paths that are used.

Parameters
[out]incpaths- Pass in a llvm::SmallVector<std::string, N> with sufficiently sized N, to hold the result of the call.
[in]withSystem- if true, incpaths will also contain system include paths (framework, STL etc).
[in]withFlags- if true, each element in incpaths will be prefixed with a "-I" or similar, and some entries of incpaths will signal a new include path region (e.g. "-cxx-isystem"). Also, flags defining header search behavior will be included in incpaths, e.g. "-nostdinc".

Definition at line 515 of file CppInterOpInterpreter.h.

References CppInternal::utils::CopyIncludePaths(), and getCI().

Referenced by Cpp::GetIncludePaths().

◆ getRedirectionFileForOutOfProcess()

FILE * CppInternal::Interpreter::getRedirectionFileForOutOfProcess ( int  FD)
inline

Definition at line 264 of file CppInterOpInterpreter.h.

◆ getSema()

clang::Sema & CppInternal::Interpreter::getSema ( ) const
inline

◆ getSymbolAddress() [1/2]

llvm::Expected< llvm::orc::ExecutorAddr > CppInternal::Interpreter::getSymbolAddress ( clang::GlobalDecl  GD) const
inline
Returns
the ExecutorAddr of a GlobalDecl. This interface uses the CodeGenModule's internal mangling cache to avoid recomputing the mangled name.

Definition at line 321 of file CppInterOpInterpreter.h.

References compat::getSymbolAddress(), and makeEngineOnce().

Referenced by getAddressOfGlobal().

◆ getSymbolAddress() [2/2]

llvm::Expected< llvm::orc::ExecutorAddr > CppInternal::Interpreter::getSymbolAddress ( llvm::StringRef  IRName) const
inline
Returns
the ExecutorAddr of a given name as written in the IR.

Definition at line 331 of file CppInterOpInterpreter.h.

References compat::getSymbolAddress(), and makeEngineOnce().

◆ getSymbolAddressFromLinkerName()

llvm::Expected< llvm::orc::ExecutorAddr > CppInternal::Interpreter::getSymbolAddressFromLinkerName ( llvm::StringRef  LinkerName) const
inline
Returns
the ExecutorAddr of a given name as written in the object file.

Definition at line 342 of file CppInterOpInterpreter.h.

References compat::getSymbolAddressFromLinkerName().

Referenced by getAddressOfGlobal().

◆ isInSyntaxOnlyMode()

bool CppInternal::Interpreter::isInSyntaxOnlyMode ( ) const
inline

Definition at line 349 of file CppInterOpInterpreter.h.

References getCompilerInstance().

Referenced by compileFunction(), and getAddressOfGlobal().

◆ isOutOfProcess()

bool CppInternal::Interpreter::isOutOfProcess ( ) const
inline

Definition at line 257 of file CppInterOpInterpreter.h.

◆ loadLibrary()

CompilationResult CppInternal::Interpreter::loadLibrary ( const std::string &  filename,
bool  lookup 
)
inline

◆ makeEngineOnce()

void CppInternal::Interpreter::makeEngineOnce ( ) const
inline

Definition at line 308 of file CppInterOpInterpreter.h.

Referenced by getSymbolAddress(), and getSymbolAddress().

◆ operator clang::Interpreter &()

CppInternal::Interpreter::operator clang::Interpreter & ( )
inline

Definition at line 255 of file CppInterOpInterpreter.h.

◆ operator const clang::Interpreter &()

CppInternal::Interpreter::operator const clang::Interpreter & ( ) const
inline

Definition at line 254 of file CppInterOpInterpreter.h.

◆ Parse()

llvm::Expected< clang::PartialTranslationUnit & > CppInternal::Interpreter::Parse ( llvm::StringRef  Code)
inline

Definition at line 294 of file CppInterOpInterpreter.h.

Referenced by Cpp::ForceCodeGen(), and process().

◆ ParseAndExecute()

llvm::Error CppInternal::Interpreter::ParseAndExecute ( llvm::StringRef  Code,
clang::Value *  V = nullptr 
)
inline

Definition at line 302 of file CppInterOpInterpreter.h.

Referenced by compileFunction(), and evaluate().

◆ process()

CompilationResult CppInternal::Interpreter::process ( const std::string &  input,
clang::Value *  V = 0,
clang::PartialTranslationUnit **  PTU = nullptr,
bool  disableValuePrinting = false 
)
inline

Maybe transform the input line to implement cint command line semantics (declarations are global) and compile to produce a module.

Definition at line 385 of file CppInterOpInterpreter.h.

References Execute(), kFailure, kSuccess, and Parse().

Referenced by declare().

◆ toString()

std::string CppInternal::Interpreter::toString ( const char *  type,
void *  obj 
)
inline

Definition at line 556 of file CppInterOpInterpreter.h.

◆ Undo()

llvm::Error CppInternal::Interpreter::Undo ( unsigned  N = 1)
inline

Definition at line 306 of file CppInterOpInterpreter.h.

References compat::Undo().

Referenced by undo().

◆ undo()

CompilationResult CppInternal::Interpreter::undo ( unsigned  N = 1)
inline

Definition at line 562 of file CppInterOpInterpreter.h.

References kFailure, kSuccess, and Undo().


The documentation for this class was generated from the following file: