-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSolidLang.h
More file actions
85 lines (63 loc) · 2.14 KB
/
SolidLang.h
File metadata and controls
85 lines (63 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef SOLID_LANG_SOLIDLANG_H
#define SOLID_LANG_SOLIDLANG_H
#include <llvm/IR/Module.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/Scalar/GVN.h>
#include <llvm/Transforms/InstCombine/InstCombine.h>
#include <llvm/Transforms/Utils.h>
#include <llvm/MC/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Support/raw_ostream.h>
#include "llvm/Support/CommandLine.h"
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/TargetParser/Host.h>
#include "Lexer.h"
#include "Parser.h"
#include "IRGenerator.h"
#include "JIT.h"
#include "BuiltIns.h"
using namespace llvm;
using namespace llvm::orc;
class SolidLang {
public:
SolidLang(std::string InputFile, std::string OutputFile, bool PrintIR) : InputFile(std::move(InputFile)),
OutputFile(std::move(OutputFile)),
PrintIR(PrintIR) {}
int Start();
private:
FILE *In;
std::string InputFile;
std::string OutputFile;
bool PrintIR;
std::unique_ptr<JIT> JIT;
std::unique_ptr<LLVMContext> Context;
std::unique_ptr<class Module> Module;
std::unique_ptr<Lexer> Lexer;
std::unique_ptr<Parser> Parser;
std::unique_ptr<IRBuilder<>> Builder;
std::unique_ptr<ExpressionVisitor> Visitor;
std::map<std::string, AllocaInst *> ValuesByName;
std::map<std::string, std::unique_ptr<FunctionDeclaration>> FunctionDeclarations;
ExitOnError OnErrorExit;
void ProcessInput();
void InitLLVM();
int WriteObjectFile();
void HandleFunction(Expression *ParsedExpression);
void HandleNative(std::unique_ptr<FunctionDeclaration> Declaration);
void HandleTopLevelExpression(Expression *ParsedExpression);
bool IsRepl() {
return InputFile == "-";
}
bool HasOutputFile() {
return OutputFile != "-";
}
void IfReplPrint(const char *Message) {
if (IsRepl()) {
fprintf(stderr, "%s", Message);
}
}
};
#endif