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
17
namespace
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
36
class
Compiler
37
{
38
std::vector<Library *> default_libraries_;
39
bf::SLRParser<ParserGrammarType> parser_;
40
41
public
:
42
static
void
InitializeGlobalCompilerRuntime
();
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
Error.h
Library.h
Node.h
Parser.h
Scene.h
unlogic::Compiler
Definition
Compiler.h:37
unlogic::Compiler::InitializeGlobalCompilerRuntime
static void InitializeGlobalCompilerRuntime()
Definition
Compiler.cpp:27
unlogic::Compiler::Compiler
Compiler()=delete
unlogic::Compiler::Compile
std::expected< Program, CompilationError > Compile(std::string_view program_text, std::vector< bf::Token< ParserGrammarType > > *tokens=nullptr)
Definition
Compiler.cpp:34
unlogic::Program
Definition
Compiler.h:20
unlogic::Program::operator()
void operator()(Scene *scene)
Definition
Compiler.cpp:14
unlogic::Program::Program
Program(std::unique_ptr< llvm::orc::LLJIT > jit)
Definition
Compiler.h:26
unlogic::Program::Program
Program()=delete
unlogic
Definition
Compiler.h:18
unlogic::CompilationError
std::variant< Error, bf::Error, llvm::Error > CompilationError
Definition
Compiler.h:34
unlogic::Scene
Definition
Scene.h:14
unlogic
src
compiler
Compiler.h
Generated by
1.9.8