unlogic
Loading...
Searching...
No Matches
Compiler.h
Go to the documentation of this file.
1//
2// Created by nathan on 6/8/24.
3//
4
5#ifndef UNLOGIC_COMPILER_H
6#define UNLOGIC_COMPILER_H
7
8#include <expected>
9#include <llvm/ExecutionEngine/Orc/LLJIT.h>
10#include <variant>
11#include "Error.h"
12#include "Library.h"
13#include "graphic/Scene.h"
14#include "parser/Node.h"
15#include "parser/Parser.h"
16
17namespace unlogic
18{
19 class Program
20 {
21 friend class Compiler;
22
23 std::unique_ptr<llvm::orc::LLJIT> jit_;
24
25 protected:
26 explicit Program(std::unique_ptr<llvm::orc::LLJIT> jit) : jit_(std::move(jit)) {}
27
28 public:
29 void operator()(Scene *scene);
30
31 Program() = delete;
32 };
33
34 using CompilationError = std::variant<Error, bf::Error, llvm::Error>;
35
37 {
38 std::vector<Library *> default_libraries_;
39 bf::SLRParser<ParserGrammarType> parser_;
40
41 public:
43
44 std::expected<Program, CompilationError> Compile(std::string_view program_text, std::vector<bf::Token<ParserGrammarType>> *tokens = nullptr);
45
46 Compiler() = delete;
47 Compiler(std::vector<Library *> default_libraries = {});
48 };
49} // namespace unlogic
50
51#endif // UNLOGIC_COMPILER_H
static void InitializeGlobalCompilerRuntime()
Definition Compiler.cpp:27
std::expected< Program, CompilationError > Compile(std::string_view program_text, std::vector< bf::Token< ParserGrammarType > > *tokens=nullptr)
Definition Compiler.cpp:34
void operator()(Scene *scene)
Definition Compiler.cpp:14
Program(std::unique_ptr< llvm::orc::LLJIT > jit)
Definition Compiler.h:26
std::variant< Error, bf::Error, llvm::Error > CompilationError
Definition Compiler.h:34