LLVM  4.0.0
LambdaResolver.h
Go to the documentation of this file.
1 //===-- LambdaResolverMM - Redirect symbol lookup via a functor -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Defines a RuntimeDyld::SymbolResolver subclass that uses a user-supplied
11 // functor for symbol resolution.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
16 #define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
17 
18 #include "llvm/ADT/STLExtras.h"
20 #include <memory>
21 
22 namespace llvm {
23 namespace orc {
24 
25 template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
27 public:
28 
29  LambdaResolver(DylibLookupFtorT DylibLookupFtor,
30  ExternalLookupFtorT ExternalLookupFtor)
31  : DylibLookupFtor(DylibLookupFtor),
32  ExternalLookupFtor(ExternalLookupFtor) {}
33 
34  JITSymbol findSymbolInLogicalDylib(const std::string &Name) final {
35  return DylibLookupFtor(Name);
36  }
37 
38  JITSymbol findSymbol(const std::string &Name) final {
39  return ExternalLookupFtor(Name);
40  }
41 
42 private:
43  DylibLookupFtorT DylibLookupFtor;
44  ExternalLookupFtorT ExternalLookupFtor;
45 };
46 
47 template <typename DylibLookupFtorT,
48  typename ExternalLookupFtorT>
49 std::unique_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
50 createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
51  ExternalLookupFtorT ExternalLookupFtor) {
53  return make_unique<LR>(std::move(DylibLookupFtor),
54  std::move(ExternalLookupFtor));
55 }
56 
57 } // End namespace orc.
58 } // End namespace llvm.
59 
60 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
Represents a symbol in the JIT.
Definition: JITSymbol.h:113
std::unique_ptr< LambdaResolver< DylibLookupFtorT, ExternalLookupFtorT > > createLambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
LambdaResolver(DylibLookupFtorT DylibLookupFtor, ExternalLookupFtorT ExternalLookupFtor)
JITSymbol findSymbolInLogicalDylib(const std::string &Name) final
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
Symbol resolution.
Definition: JITSymbol.h:165
JITSymbol findSymbol(const std::string &Name) final
This method returns the address of the specified function or variable.