unlogic
Loading...
Searching...
No Matches
Library.h
Go to the documentation of this file.
1//
2// Created by nathan on 6/18/24.
3//
4
5#ifndef UNLOGIC_LIBRARY_H
6#define UNLOGIC_LIBRARY_H
7
8#include <string>
9#include <utility>
10#include <llvm/ExecutionEngine/Orc/Core.h>
11#include <llvm/ExecutionEngine/Orc/LLJIT.h>
13
14namespace unlogic
15{
16 struct LibrarySymbol;
17
18 struct Library
19 {
20 std::string name;
21 std::vector<LibrarySymbol*> symbols;
22
23 Library(std::string name) : name(std::move(name)) {}
24
25 Library() = delete;
26 };
27
29 {
30 char const *name;
31 llvm::orc::ExecutorSymbolDef symbol;
32
33 using DefineType = std::function<void(llvm::LLVMContext&, llvm::Module&)>;
35
36 LibrarySymbol(Library &lib, char const *name, void *native, DefineType populate_scope) : name(name), Define(std::move(populate_scope))
37 {
38 this->symbol = {
39 llvm::orc::ExecutorAddr::fromPtr(native),
40 llvm::JITSymbolFlags(),
41 };
42
43 lib.symbols.push_back(this);
44 };
45 };
46}
47
48#endif //UNLOGIC_LIBRARY_H
DefineType Define
Definition Library.h:34
std::function< void(llvm::LLVMContext &, llvm::Module &)> DefineType
Definition Library.h:33
char const * name
Definition Library.h:30
LibrarySymbol(Library &lib, char const *name, void *native, DefineType populate_scope)
Definition Library.h:36
llvm::orc::ExecutorSymbolDef symbol
Definition Library.h:31
std::string name
Definition Library.h:20
Library(std::string name)
Definition Library.h:23
std::vector< LibrarySymbol * > symbols
Definition Library.h:21