LLVM  3.7.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 #include <vector>
22 
23 namespace llvm {
24 namespace orc {
25 
26 template <typename ExternalLookupFtorT, typename DylibLookupFtorT>
28 public:
29 
30  LambdaResolver(ExternalLookupFtorT ExternalLookupFtor,
31  DylibLookupFtorT DylibLookupFtor)
32  : ExternalLookupFtor(ExternalLookupFtor),
33  DylibLookupFtor(DylibLookupFtor) {}
34 
35  RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) final {
36  return ExternalLookupFtor(Name);
37  }
38 
40  findSymbolInLogicalDylib(const std::string &Name) final {
41  return DylibLookupFtor(Name);
42  }
43 
44 private:
45  ExternalLookupFtorT ExternalLookupFtor;
46  DylibLookupFtorT DylibLookupFtor;
47 };
48 
49 template <typename ExternalLookupFtorT,
50  typename DylibLookupFtorT>
51 std::unique_ptr<LambdaResolver<ExternalLookupFtorT, DylibLookupFtorT>>
52 createLambdaResolver(ExternalLookupFtorT ExternalLookupFtor,
53  DylibLookupFtorT DylibLookupFtor) {
55  return make_unique<LR>(std::move(ExternalLookupFtor),
56  std::move(DylibLookupFtor));
57 }
58 
59 } // End namespace orc.
60 } // End namespace llvm.
61 
62 #endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) final
This method returns the address of the specified function or variable.
RuntimeDyld::SymbolInfo findSymbolInLogicalDylib(const std::string &Name) final
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
LambdaResolver(ExternalLookupFtorT ExternalLookupFtor, DylibLookupFtorT DylibLookupFtor)
std::unique_ptr< LambdaResolver< ExternalLookupFtorT, DylibLookupFtorT > > createLambdaResolver(ExternalLookupFtorT ExternalLookupFtor, DylibLookupFtorT DylibLookupFtor)
Information about a named symbol.
Definition: RuntimeDyld.h:47